Олимпиадный тренинг

Задача 38372. triangular key


Задача

Темы:
Indiana Jones has the key to the door leading to the secret riches of the Incas. The key has the shape of a regular triangle, which, in turn, is divided into n2 small regular triangles, each of which contains one decimal digit. An example of a key is shown below.


Jones inserted the triangle into the corresponding triangular hole in the door, and... it didn't open. Perhaps he inserted the key incorrectly, because it can be inserted in three ways. Due to the fact that Jones has only one attempt left to open the doors (if he fails, he will be killed by the bloodthirsty Incas already overtaking him), he wants to know what the key will look like when it is inserted into the door in two other ways. After that, he will make the right choice. He asked you, as one of his two assistants, to show him only one of two possible options. The appearance of the key above, when turned counterclockwise and clockwise, is shown in the figure below.


Since you don't want Indiana dead and want your share of the treasure, you'll have to help him!

Input
The first line of the input file contains a single integer n (1 ≤ n ≤ 100). The next n lines describe the triangle itself. The input file line numbered i + 1 contains the 2i - 1 digit — the content of the i-th row of the triangle key.

The last line contains the word counterclockwise if the triangle needs to be rotated counterclockwise, and clockwise otherwise.

Imprint
Output the type of key when it is turned in the desired direction. Describe the triangle in the same format as in the input file.
 
Examples
# Input Output
1 3
1
2 3 4
5 6 7 8 9
counterclockwise

4 8 7 
1 3 2 6 5 
2 3
1
2 3 4
5 6 7 8 9
clockwise

7 6 2 
9 8 4 3 1