/** */ #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int maxn = 17; const ll Mod = 1e9+7; const ll inf = 0x3f3f3f3f; ll add[1005][2]; ll a[1005][1005]; int row[1005], col[1005]; int main() { int T, n, m, q, x, y, z; cin>>T; while(T--) { scanf("%d%d%d",&n,&m,&q); for(int i = 0; i