402186: GYM100687 L Snake (B)

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

L. Snake (B)time limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

Dr. Rawan’s students found the warmup exercise to be very easy and asked for a more challenging task. Therefore, Dr. Rawan asked them to write a program that will help the snake reach the exit door.

Given the state of a snake on the 16x32 grid as described before, your task is to find any sequence of moves (using the symbols >, <, ^ and v) that will allow the snake to reach the exit cell. The sequence of moves should not make the snake intersect itself.

Input

Each line of the first 16 lines of input contains 32 characters, which represent the state of the snake on the grid.

The number of dots that are not reachable from the borders doesn't exceed 32, and all characters on the border are dots.

The length of the snake doesn't exceed 75 cells.

Output

Print a sequence of moves that will make the snake reach the exit cell without intersecting itself. The sequence should contain at most 1024 characters.

If no sequence exists, print '—' (3 dashes) without the single quotes.

ExamplesInput
................................
................................
................................
................................
................................
................................
..........>v.:<<<...............
........E..v....^...............
...........v....^...............
...........>>>>>^...............
................................
................................
................................
................................
................................
................................
Output
^<<<<vv<

加入题单

上一题 下一题 算法标签: