P2033 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` | $n$ is a non-negative integer, meaning you move forward $n$ 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 $90$ degrees. | | `turn right` | Turn right by $90$ degrees. | | `turn back` | Turn around. |

Input Format

The first $8$ lines, each with $8$ 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 $1000$.

Output Format

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

Explanation/Hint

Translated by ChatGPT 5