You have an
board. Some positions have objects that, when pressed, start moving in
the direction painted on them, until they leave the board. The painted
directions are ‘>’ for rightwards, ‘<’
for leftwards, ‘’ for upwards and ‘v’ for downwards. Note,
you are only allowed to press an object if its path is currently free
from other objects. The goal of the game is to empty the board. Can you
win?
Input consists of several cases, each with and , followed by lines with characters each. Periods indicate empty cells. Assume that both and are between 1 and 100, and that there is at least one object on the board.
Print a line for each case. If there is no solution, print
“NO”. Otherwise, print “YES” followed by all
the positions of the objects (row and column, the upper left position is
(1, 1)), in the order that they should be pressed. If there is more than
one solution, you can print any one. Follow strictly the format of the
sample output.
Input
1 4 >>>> 3 3 >.v ... ^.< 2 3 ^.> .<v 2 3 ^.> .<v 2 4 <^>^ >>v<
Output
YES 1 4 1 3 1 2 1 1 NO YES 1 1 1 3 2 2 2 3 YES 2 3 1 3 2 2 1 1 NO