#include #include #include #include using namespace std; typedef long long ll; const ll N = 1001; ll n,m,q,a[N][N],b[N][N],t1[N],t2[N],t3[N],t4[N],i,j,T,x,y,t; int main() { scanf("%I64d",&T); while (T--){ scanf("%I64d%I64d%I64d",&n,&m,&q); for (i=1;i<=n;i++) for (j=1;j<=m;j++)scanf("%I64d",&a[i][j]); for (i=1;i<=n;i++)t1[i]=i; for (i=1;i<=m;i++)t2[i]=i; memset(t3,0,sizeof(t3)); memset(t4,0,sizeof(t4)); while (q--) { scanf("%I64d%I64d%I64d",&t,&x,&y); if (t==1)swap(t1[x],t1[y]); if (t==2)swap(t2[x],t2[y]); if (t==3)t3[t1[x]]+=y; if (t==4)t4[t2[x]]+=y; } for (i=1;i<=n;i++){ for (j=1;j