#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main() {
int t;
cin>>t;
for (t=t;t>0;t--){
int n,m,q;
cin>>n>>m>>q;
int a[m+1][n+1]={0};
int opt,x,c;
for (q=q;q>0;q--){
cin>>opt>>x>>c;
if (opt=0){
for(int i=1;i<=m;i++){
a[x][i]=c;
}
}else{
for(int i=1;i<=m;i++){
a[i][x]=c;
}
}
for (int i=1;i<=m;i++){
for (int j=1;j<=n;j++){
if(j==n){
cout<<a[i][j];
}else{
cout<<a[i][j]<<" ";
}
}cout<<endl;
}
}
}
return 0;
}
自认为码风极其难看。求调