Care of Magical Creatures#2347

Care of Magical Creatures

1 secondo
64 megabyte
Facile

On a rectangular enclosed platform, Ogrid scattered bundles of cabbage, placed a small centipod there, and tasked the students with feeding this creature. The centipod is so dull that it only moves in a straight line until it encounters an obstacle or its own body. Using spells, the centipod can be turned left or right. When eating cabbage, the centipod grows in size.

Write a program that simulates feeding the centipod. The centipod moves at a speed of one cell per second. If a command is given at the beginning of a second, the centipod turns its head in the specified direction (the turn is instantaneous), and then moves in the direction its head is facing. If no command is given, the centipod continues moving in the same direction as in the previous second. If there is a platform fence or its own body ahead, the centipod stays in place; otherwise, it moves one cell forward. If there is cabbage on the cell, the length of the centipod increases instantly by one unit (in this case, the tail does not move). The centipod's head is on the first segment of the body and can turn by any angle that is a multiple of degrees.

Input

The first line of the input file contains two integers separated by a space: the platform's dimensions (1 \leq N \leq 100) and (1 \leq M \leq 100). Then follow lines, each containing characters describing the initial state of the platform. Character "." (dot) denotes an empty cell, character "@" denotes a cell with cabbage. Character "

Output

Output lines of characters describing the final state of the platform. The centipod's head is shown by the symbol "

Esempi

Esempio 1

Loading
Loading