#P373. 练64.2 图像旋转翻转变换

练64.2 图像旋转翻转变换

Description

Given the grayscale values of pixels in an m×nm \times n image, perform a series of operations in sequence and output the final image.
The possible operations and their corresponding characters are as follows:
AA: Rotate 9090 degrees clockwise;
BB: Rotate 9090 degrees counterclockwise;
CC: Flip horizontally;
DD: Flip vertically.

Input Format

First line contains two positive integers mm and nn, representing the number of rows and columns of the image, separated by a single space. 1m1001 \le m \le 100, 1n1001 \le n \le 100.
Next mm lines, each containing nn integers, represent the grayscale values of each pixel in the image, with adjacent numbers separated by a single space. Grayscale values range from 00 to 255255.
Next line contains a string ss composed of characters AA, BB, CC, and DD, representing the sequence of operations to be performed. The length of ss is between 11 and 100100.

Output Format

Output mm' lines, each containing nn' integers, representing the grayscale values of the final image. Here mm' is the number of rows in the final image, and nn' is the number of columns. Adjacent integers are separated by a single space.

Sample

2 3
10 0 10
100 100 10
AC
10 100
0 100
10 10