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: 96ms
Memory: 24300kB
Author: Amber
In contest: 1123

def rotate(a):
    n,m=len(a),len(a[0])
    b=[[0 for j in range(n)] for i in range(m)]
    for i in range(len(b)):
        for j in range(len(b[0])):
            b[i][j]=a[n-1-j][i]
    return b

for case in range(int(input())):
    n,m,k=list(map(int,input().split()))
    a=[]
    for i in range(n):
        a.append(list(map(int,input().split())))

    times=k % 4
    while times > 0:
        a=rotate(a)
        times-=1


    for i in range(len(a)):
        for j in range(len(a[0])-1):
            print(a[i][j],end=" ")
        print(a[i][-1])
    print()