#include "testlib.h"
#include<stdio.h>
#include<math.h>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,car[505][505],vis[505][505],exi[505];
int s;
int main(int argc,char *argv[]){
    registerTestlibCmd(argc, argv);
	int T;
	T=inf.readInt();
	while(T--){
		n=inf.readInt();
		memset(vis,0,sizeof(vis));
		for(int i=1;i<=n;i++){
			for(int t=1;t<=n;t++){
				car[i][t]=inf.readInt();
			}
		}
		int m=ouf.readInt();
		if(m==-1){
			quitf(_wa, "exist a solution but you don't find it.");
		}
		for(int i=1;i<=m;i++){
			int a,b,c,d;
			a=ouf.readInt();
			b=ouf.readInt();
			c=ouf.readInt();
			d=ouf.readInt();
			if(a<=0||a>n||b<=0||b>n||c<=0||c>n||d<=0||d>n){
				quitf(_wa, "you swapped a card not existed.");
			}
			if(vis[a][b]||vis[c][d]){
				quitf(_wa, "exist a card swapped twice.");
			}
			vis[a][b]=vis[c][d]=1;
			swap(car[a][b],car[c][d]);
		}
		for(int i=1;i<=n;i++){
			memset(exi,0,sizeof(exi));
			for(int t=1;t<=n;t++){
				exi[car[i][t]]=1;
			}
			for(int t=1;t<=n;t++){
				if(!exi[t]){
					quitf(_wa, "exist a kind of card which a person don't hold.");
				}
			}
		}
	}
	quitf(_ok,"your solution is correct.");
}
