Character Wheels
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

You are given one    character wheels, and it is guaranteed that n is even. Please implement these following operations:  

  1. Clockwise/Counter-clockwise rotate the x-th wheel    times. Rotating one time means rotatting 90 degrees. The instruction is L/R x yR indicates rotating clockwise and L indicates rotating counter-clockwise. For example, R 1 3 means rotate the 1-st wheel 3 times clockwise. 
  2. Print all the wheels, the instruction is P.


输入描述:

First line contains one integer 𝑛 ( 4 ≤ 𝑛 ≤ 50), indicates the size of the wheels. 
Then followed the wheels.
After that, one line contains one integer 𝑚 ( 1 ≤ 𝑚 ≤ 100), indicates the number ofoperations.
Then followed 𝑚 lines, one line one instruction.
it is guaranteed that at least there is one P instruction and the wheels only contain lowercase letters.

输出描述:

If the instruction is P, then print all the wheels.
示例1

输入

复制
4
abcd
cabe
fgha
edbe 
5
L 1 1 
P
R 1 3
L 2 1 
P

输出

复制
deae
cabb
bghd
acfe
ebde
abhf
eagc
dcba