Problem: Ronak’s  class teacher gives him an NxN matrix.
 Then, she gives him M numbers. Every number is an angle, the angle by which he has to rotate the matrix in clockwise direction.  (The angles are multiples of 90.)
 Help him with the task.


Input
First line consists of two numbers N and M.
 The following N lines contain  N numbers each (representing the matrix). 
 The next M lines contain one number each, representing the angle by which the matrix is to be rotated.

Output
For M problems, generate M appropriately rotated matrices, each seperated by a new line.  

Constraints

1 ≤ N,M ≤ 100


Example
Input:
4 2
1 2 3 4
4 5 6 7
6 8 4 3
8 1 4 7
90
180

Output:
8 6 4 1
1 8 5 2
4 4 6 3
7 3 7 4

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

Solution (in PYTHON):

Solution:
n,m=map(int, raw_input().split())
a=[ raw_input().split() for j in xrange(n) ]
while m>0:
	m-=1
	ang=input()
	ang/=90
	ang%=4
	if(ang==1):
		for j in xrange(0,n):
			for i in xrange(n-1,-1,-1):
				print a[i][j],
			print 
	elif(ang==2):
		for i in xrange(n-1,-1,-1):
			for j in xrange(n-1,-1,-1):
				print a[i][j],
			print 
	elif(ang==3):
		for i in xrange(n-1,-1,-1):
			for j in xrange(0,n):
				print a[j][i],
			print 
	else:
		for row in a:
			print " ".join(map(str,row))