m,n=map(int,input().split(' '))
x=[]
for i in range(m):
a=list(map(int,input().split(' ')))
x.append(a)
k=int(input())
kk=[]
for i in range(k):
ks=list(input().split(' '))
kk.append(ks)
for i in range(k):
if kk[i][0]=='r':
x[int(kk[i][1])-1],x[int(kk[i][2])-1]=x[int(kk[i][2])-1],x[int(kk[i][1])-1]
if kk[i][0]=='c':
for j in range(m):
x[j][int(kk[i][1])-1],x[j][int(kk[i][2])-1]=x[j][int(kk[i][2])-1],x[j][int(kk[i][1])-1]
for i in x:
print(*i)