#include<bits/stdc++.h>
using namespace std;
int a[1010][1010],b[1010];
int main(){
int n,m,p,x,y,z;
char tmp;
cin >> n >> m >> p;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >> tmp;
a[i][j]=tmp-'0';
}
}
for(int i=1;i<=p;i++){
cin >> x >> y >> z;
if(x!=3){
if(x==1){
for(int j=1;j<=n;j++){
swap(a[y][j],a[z][j]);
}
}else{
for(int j=1;j<=n;j++){
swap(a[j][y],a[j][z]);
}
}
}else{
cout<<a[y][z]<<endl;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cout << a[i][j];
}
cout << endl;
}
return 0;
}