/*
after dusk passed,
there is a starry sky.
*/
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define len(a) (int)a.size()
using namespace std;
const int N=1e6+100;
int n,m,k,a[N];
deque <int> q[3110];
inline int read()
{
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
signed main()
{
	freopen("1.in","r",stdin);
	read();
	n=read();m=read();k=read();
	for (int i=1;i<=m;i++) a[i]=read();
	freopen("1.out","r",stdin);
	int cnt=read();
	assert(cnt<=2*m&&cnt>=m);
	for (int i=1,pos=1;i<=cnt;i++)
	{
		int op=read();
		if (op==1)
		{
			int s=read();
			if (!q[s].empty()&&q[s].back()==a[pos]) q[s].pop_back();
			else q[s].push_back(a[pos]);
			pos++;
		}
		else
		{
			int a=read(),b=read();
			if (q[a].front()!=q[b].front())
			{
				cerr<<i<<endl;
				return 0;
				// printf("NO %d\n",i)
			}
			assert(!q[a].empty()&&!q[b].empty()&&q[a].front()==q[b].front());
			q[a].pop_front();q[b].pop_front();
		}
	}
	bool bl=1;
	for (int i=1;i<=n;i++) assert(q[i].empty());
	printf("OK\n");
}