#include <bits/stdc++.h>
using namespace std;
int T,n,m,k,a[2000005],t;
deque<int> dq[305];
int main (int argc, char** argv)
{
	FILE* fin=fopen (argv[1],"r");
	FILE* fout=fopen (argv[2],"r");
	fscanf (fin,"%d",&T);
	for (int TT=1;TT<=T;TT++)
	{
		fscanf (fin,"%d%d%d",&n,&m,&k);
		for (int i=1;i<=n;i++)
			fscanf (fin,"%d",a+i);
		int now=1;
		fscanf (fout,"%d",&t);
		for (int tt=1;tt<=t;tt++)
		{
			int opt,x,y;
			fscanf (fout,"%d%d",&opt,&x);
			if (opt==1)
			{
				if (!dq[x].empty() && dq[x].back()==a[now])
					dq[x].pop_back(), now++;
				else dq[x].push_back(a[now++]);
			}
			else
			{
				fscanf (fout,"%d",&y);
				if (dq[x].empty())
				{
					printf ("Wrong Answer: Invalid operation in task %d, step %d: 2 %d %d\n",TT,tt,x,y);
					printf ("Stack %d empty\n",x);
					return 1;
				}
				if (dq[y].empty())
				{
					printf ("Wrong Answer: Invalid operation in task %d, step %d: 2 %d %d\n",TT,tt,x,y);
					printf ("Stack %d empty\n",y);
					return 1;
				}
				if (dq[x].front()!=dq[y].front())
				{
					printf ("Wrong Answer: Invalid operation in task %d, step %d: 2 %d %d\n",TT,tt,x,y);
					printf ("The bottom of stack %d and %d differ\n",x,y);
					return 1;
				}
				dq[x].pop_front();
				dq[y].pop_front();
			}
		}
		for (int i=1;i<=n;i++)
			if (!dq[i].empty())
			{
				printf ("Wrong Answer: Stack %d not empty after task %d\n",i,TT);
				return 1;
			}
	}
	puts ("OK Accepted");
	return 0;
}
