Start: Apr, 17, 2017 10:00:00
Python程序设计基础培训第三次作业
End: Apr, 23, 2017 14:00:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 132ms
Memory: 21688kB
Author: 15957554881
In contest: 1087

tcase=int(raw_input())
for case in range(tcase):
    data = []
    a,b,c=map(int,raw_input().strip().split())
    for i in range(a):
        data.append(map(int,raw_input().strip().split()))

    line=len(data)
    row=len(data[0])
    if c % 4==0:
        for i in range(len(data)):
            for j in range(len(data[0])):
                print data[i][j],
            print
    elif c % 4==1:
        L=[]
        R=[]
        for i in range(row):                                
            for j in range(line):                        
                L.append(data[line-j-1][i])  
            R.append(L)
            L=[]
        for i in range(len(R)):
            for j in range(len(R[0])):
                print R[i][j],
            print
    elif c % 4==2:
        L=[]
        R=[]
        for i in range(line):                                
            for j in range(row):                        
                L.append(data[line-i-1][row-j-1])  
            R.append(L)
            L=[]
        for i in range(len(R)):
            for j in range(len(R[0])):
                print R[i][j],
            print
    elif c % 4==3:
        L=[]
        R=[]
        for i in range(row):                                
            for j in range(line):                        
                L.append(data[j][row-i-1])  
            R.append(L)
            L=[]
        for i in range(len(R)):
            for j in range(len(R[0])):
                print R[i][j],
            print
    print