Velociraptor is fit

When a velociraptor does not smell human blood, takes advantage to do some exercise and mark its territory. In a rectangular room n×mn \times m with obstacles, our friend starts running trying to keep the direction and the sense of its movement while it is possible, leaving a pheromone trace. Under any circumstances it will go out of the room, nor will cross an obstacle, nor will cross a square that was crossed previously. In these cases, velociraptor will turn 90 degrees to the right. If, even turning 90 degrees, the velociraptor could not continue, it would stop.

Implement a program that prints the squares where the velociraptor has been before stopping. The velociraptor always starts in the central position of the room, moving towards north.

Input

The input describes a room. The first line has the number of rows nn and the number of columns mm. It is fulfilled that 2<n,m<2002 < n, m < 200. nn as well as mm are odd numbers. nn lines follow, with mm characters each one. An asterisk indicates an obstacle. The central position is always free.

Output

Your program must print the board with a ’V’ in each position where the velociraptor has been.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:14:39.584Z

© Jutge.org, 2006–2026.
https://jutge.org