시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 78 43 32 52.459%

문제

동혁이는 회전을 좋아한다. 동혁이는 표에 글자를 채워넣은 다음에 이를 회전시키려고 한다.

먼저 A4용지에 R*C크기의 표를 그리고, 각 칸에 알파벳 소문자를 채워 넣는다.

그 다음 45의 배수인 K를 고른 뒤에, 그 각도만큼 시계방향으로 회전 시킨다.

이 때, 동혁이가 보는 표의 모습을 출력하는 것이다. (동혁이는 마법을 부려 알파벳은 종이를 돌려도 항상 제모습 유지하도록 만들었다)

입력

첫째 줄에 R과 C가 공백으로 구분되어 주어진다. 그 다음 R개의 줄에는 동혁이가 그린 표에 적혀있는 알파벳이 주어진다. (1 ≤ R ≤ 10, 1 ≤ C ≤ 10)

마지막 줄에는 K가 주어진다. 이 수는 0보다 크거나 같고, 360보다 작거나 같은 45의 배수이다. 

출력

예제와 같은 형태로 회전 시켰을 때의 모습을 출력하면 된다. 회전 시켰을 때,  다양한 경우가 나올 수 있는데, 이럴 때는 줄의 수가 가장 작은 것을 출력하면 된다. 어떤 줄은 공백으로 시작할 수도 있고, 공백으로 끝날 수도 있다. 이 때, 공백으로 시작하는 경우에는 공백을 모두 출력해야 하지만, 공백으로 끝나는 경우에는 공백을 출력하지 않고 무시한다. (모든 줄은 알파벳 소문자로 끝나야 한다.)

예제 입력 1

3 5
damir
marko
darko
45

예제 출력 1

  d
 m a
d a m
 a r i
  r k r
   k o
    o

힌트

W3sicHJvYmxlbV9pZCI6IjI5NDkiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiI0NVx1YjNjNCIsImRlc2NyaXB0aW9uIjoiPHA+XHViM2Q5XHVkNjAxXHVjNzc0XHViMjk0IFx1ZDY4Y1x1YzgwNFx1Yzc0NCBcdWM4OGJcdWM1NDRcdWQ1NWNcdWIyZTQuIFx1YjNkOVx1ZDYwMVx1Yzc3NFx1YjI5NCBcdWQ0NWNcdWM1ZDAgXHVhZTAwXHVjNzkwXHViOTdjIFx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