13559 - Bingo rotation   

Description

Gregory is planning to play bingo on Freddy's birthday! To ensure Freddy wins the game, Gregory made a special bingo card for Freddy and determined the number sequence for everyone to mark in order. However, it would be too obvious if he gives Freddy a certain bingo card, so Gregory decided to make other cards for Freddy to choose from, but also ensures Freddy would win while keeping the number sequence the same.

Here's what Gregory is going to do: Gregory had the special bingo card already, and he wants to create another bingo card by rotating the special bingo card so that the two cards seem different and both of them can win the bingo game.

Now Gregory has decided the angle he wants to rotate, please help him make the bingo card he wants.

Here are some examples for the rotated cards. The cards are rotated counterclockwise and will only be rotated by 0, 90, 180, or 270 degrees.

Input

The first line contains an integer n, which means the size of the bingo card is n * n.
The following n lines each containing n positive integers represent the special bingo card.
The last line contains an integer a (0, 90, 180, or 270), which means the angle Gregory wants to rotate.

It is guaranteed that all numbers on bingo cards are less than 103

(3 ≤ n ≤ 100)

Output

Output contains n lines, each line has n integers, representing the rotated bingo card.

Do not print extra space at the end of the line.

Sample Input  Download

Sample Output  Download

Tags

FlyHighHigh



Discuss