#P2033. Chessboard Dance

Chessboard Dance

Description

Dancing on a chessboard is an interesting thing. You are given a chessboard with some pieces on it, along with your initial position and facing direction. After performing a sequence of operations, output the final state of the board.

There are four operations, described as follows:

Operation Description
move n nn is a non-negative integer, meaning you move forward nn steps in your current direction. If you are about to move off the board, stop. If there is a piece in front of you, push it forward by one square.
turn left Turn left by 9090 degrees.
turn right Turn right by 9090 degrees.
turn back Turn around.

Input Format

The first 88 lines, each with 88 characters, give the board state. . means the square is empty; letters indicate pieces, and different letters indicate different pieces. Your position is represented by one of ^, <, >, v, which indicate your facing direction up, left, right, or down, respectively.

Then there are several lines, one per operation, ending with #. The number of operations does not exceed 10001000.

Output Format

Output 88 lines, each with 88 characters, representing the board and your state after the sequence of operations. The representation is the same as in the input.

......bA
.....^..
........
........
........
........
........
........
move 2
turn right
move 1
#

......>b
........
........
........
........
........
........
........

Hint

Translated by ChatGPT 5