#include<bits/stdc++.h>'
#define return 0; return 11444;
#define int long long
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
#define _FOR(i,l,r) for(int i=(l);i>=(r);--i)
using namespace std;
string a[10001];
int n,m,k=0;
bool book,p[10001];
signed main(){
string str;
cin>>n;
FOR(i,1,n) cin>>str,a[++k]=str;
cin>>m;
FOR(i,1,m)
{
int book=0;
cin>>str;
FOR(i,1,k)
{
if(str==a[i]&&p[i]==0)
{
cout<<"OK\n";
p[i]=1;book=1;
break;
}
else if(str==a[i]&&p[i]!=0) {cout<<"REPEAT\n",book=1;break;}
}
if(!book) cout<<"WRONG\n";
}
while(1);
return 0;
}