Time limit
2s
Memory limit
128 MB
The Department of Sculpture at W University built a woodcut machine to help students with repetitive woodblock work.
The machine moves a carving tool held by a robot arm in the four directions: up, down, left, and right. When a wooden board is placed under the tool, the machine automatically carves line traces on the board.
The board has N^2 points arranged at equal intervals in an N by N grid. The carving tool always starts on the top-left point.
Given the sequence of movement commands for the robot arm, print the traces left by the carving tool on the board.
If a command would move the robot arm outside the grid, the machine ignores that command and continues with the next one.
The first line contains the board size N (2 <= N <= 10). This means the points form an N by N grid.
The second line contains the robot arm's movement commands as one string without spaces. U moves up, D moves down, L moves left, and R moves right. The command string has length at most 250.
Print . for a point the robot arm never passed, | for a point it passed only vertically, - for a point it passed only horizontally, and + for a point it passed both vertically and horizontally.
The ASCII codes of these four characters are 46, 124, 45, and 43, respectively.