n,m=list(map(int,input().split()))
mat=[]
for i in range(n):
lis=list(map(int,input().split()))
mat.append(lis)
k=int(input())
mat1=[]
for i in range(k):
mat1.append(list(input().split()))
def change_matrix(matrix_input,type,a,b):
a,b=map(int,[a,b])
a=a-1
b=b-1
if type=='r':
change1=matrix_input[a]
change2=matrix_input[b]
matrix_input[a]=change2
matrix_input[b]=change1
elif type=='c':
for i in range(len(matrix_input)):
change1=matrix_input[i][a]
change2=matrix_input[i][b]
matrix_input[i][a]=change2
matrix_input[i][b]=change1
return matrix_input
for i in range(k):
t,a,b=mat1[i][0],mat1[i][1],mat1[i][2]
mat_final=change_matrix(mat,t,a,b)
mat=mat_final
for x in mat_final:
for y in x:
print(y,end=' ')
print()