Bheem and Tuntun Mausi

1

1 votes
Problem

We all know that Bheem loves to eat laddu very much. One day he asked Tuntun Mausi to give him some laddus. Then Tuntun Mausi gave him  a N*N grid and Q which denotes the number of queries for each query he will be given a number M. If the total number of primes upto are even then rotate the grid one time anticlockwise and else rotate it two times anticlockwise.

Now Bheem is very confused with the language of the problem and he find it difficult to solve it so that he can eat laddu.

If you solve it, Bheem will give you one laddu.

Input
First line of input contains N - number of rows and column
Next N lines containing N integer in each line
Next line is Q denotes the number of the query
Next M is the number explained in the question

Output
After completion of all the query on the grid output the resulted grid.

Constraints

1<= N <= 100

1<= Q<=100
1<= M <=106
number in each cell of the grid<=106
 

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?