Start: Nov, 12, 2017 10:00:00
2017秋Python程序设计基础培训第三次作业
End: Nov, 19, 2017 12:00:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 116ms
Memory: 24436kB
Author: eboyhcf
In contest: 1123

t=int(input())
a=[[[0 for i in range(100)]] for i in range(100)]
for tt in range(t):
        n,m,k=list(map(int,input().split()))
        for i in range(0,n):
            a[i]=list(map(int,input().split()))
        if k%4==1:
           for j in range(0,m):
                for i in range(n-1,-1,-1):
                               print(a[i][j],end=" ")
                print("")
        elif k%4==2:
           for i in range(n-1,-1,-1):
                for j in range(m-1,-1,-1):
                        if j==0:
                                  print(a[i][j],end="")
                        else:
                                  print(a[i][j],end=" ")
                print("")
                 
        elif k%4==3:
           for i in range(m-1,-1,-1):
                for j in range(0,n):
                            if j==n-1:
                                  print(a[j][i],end="")
                            else:
                                  print(a[j][i],end=" ")
                print("")   
        else:
           for i in range(n):
                for j in range(m):
                          if j==m-1:
                                  print(a[i][j],end="")
                          else:
                                  print(a[i][j],end=" ")
                print("")

        print("")