ac:
#include "iostream"
#include "string"
#include "map"
using std::cin;
using std::cout;
using std::endl;
using std::map;
using std::string;
int n,m;
string str;
int main() {
map<string, int>a;
cin >> n;
while (n--) {
cin >> str;
a[str] = 1;
}
cin >> m;
while (m--) {
cin >> str;
if (a[str] == 1) {
cout << "OK" << endl;
a[str] = 2;
}
else if (a[str] == 2) {
cout << "REPEAT" << endl;
}
else cout << "WRONG" << endl;
}
}