Under construction

Still being built. Things may change

Lefffft!

Time limit2sMemory limit1024 MB

Summary
Track a three-cell soldier drawn on a character grid through turn and forward-step commands, then print the grid with the soldier at its final position.
Level

Easy2 of 10

Topics
Simulation, Implementation, Matrix
Solved
No attempts yet

Problem

About two weeks passed, and the scout Smith received another urgent and important assignment. After a hurried goodbye to a dozen new friends and quick orders to his butler, he was at the airport at three in the morning.

The same parade ground. A light drizzle is falling, and the mud is knee-deep in some places and chest-deep in others. Neither the brave sergeant, who calls out commands in a cheerful voice, nor Private Pereterkin, who carries them out without complaint, minds it. Yesterday, while sweeping the parade ground, Private Pereterkin broke one rake and lost the other. As a disciplinary measure he was assigned three hours of drill, and the first of those hours is almost over.

Smith's job is to find out how accurately an average private in the army of a potential enemy performs drill movements. He photographs the parade ground from his hiding place at regular intervals and records the commands on a portable spy recorder with a directional microphone. At first Smith thought the job would be easy, but once the number of photos passed three hundred, he began to realize he would not get off so lightly.

After some thought, Smith reduced the problem to the following: given a soldier's starting position on the parade ground and the sequence of commands the soldier carries out, find the position the soldier occupies after executing all of the commands. But how to solve it? Then Smith had an idea. As soon as the sergeant paused, he took a phone out of his shirt and began dialing a familiar number...

The soldier occupies three consecutive adjacent cells of the parade ground. The following figures show how each command is carried out.

Command "Left turn"
.......  .......
.......  ...\...
..\-/..  ...|...
.......  .../...
.......  .......
Command "Right turn"
.......   .......
.......   .../...
..\-/..   ...|...
.......   ...\...
.......   .......
Command "About turn"
.......  .......
..\-/..  ../-\..
.......  .......
Command "Forward step"
.......      .......
.......      ..\-/..
..\-/..      .......
.......      .......

"Left turn" rotates the soldier 90 degrees counterclockwise in place. "Right turn" rotates the soldier 90 degrees clockwise. "About turn" turns the soldier 180 degrees. "Forward step" moves the soldier one cell in the direction he is facing.

Input

The first line contains three integers N, M, K (1≤N,M,K≤1001 \le N, M, K \le 100). The next N lines each contain M characters and describe the soldier's starting position on the parade ground.

The next K lines contain the commands given to the soldier. Smith reports in English, so the commands are also given in English. The table below gives the translations of the commands.

CommandEnglish
Left turnLeft turn
Right turnRight turn
About turnAbout turn
Forward stepForward step

The soldier is guaranteed to stay within the boundaries of the parade ground while executing the commands.

Output

Print N lines of M characters each. These lines describe the soldier's position on the parade ground after all the commands are executed.

Examples1

  1. Example 1

    Input
    4 7 4
    .......
    .......
    .../-\.
    .......
    Left turn
    Right turn
    About turn
    Forward step
    
    Expected output
    .......
    ...\-/.
    .......
    .......