#include #include #include #include #include #define maxn 1000007 #define modp 1000000007 typedef long long LL; typedef unsigned long long ULL; int n,m,T,tot; LL K; using namespace std; LL qpow(int x, int y) { if (y<=0) return 1; LL res=qpow(x,y>>1); res*=res; if (y&1) res*=x; return res; } int c[2000][2000]; int ax[2000],ay[2000],xx[2000],yy[2000]; int main() { scanf("%d",&T); while (T--) { int q; scanf("%d%d%d",&n,&m,&q); tot=n*m; memset(ax,0,sizeof(ax)); memset(ay,0,sizeof(ay)); memset(xx,0,sizeof(xx)); memset(yy,0,sizeof(yy)); for (int i=0;i