rt,人眼比较 wa 的点输出似乎一样?///
#include<bits/stdc++.h>
using namespace std;
int n, m; string op, ad;
map <string, int> ss;
bool check(string s){
int d = 0, m = 0, x = 0; bool f = 0, ff = 0;
for (int i = 0; i < s.size(); i++){
if (s[i] == '.') ++d;
else if (s[i] == ':') ++m;
if (s[i] >= '0' && s[i] <= '9') {
x = x * 10 + s[i] - '0';
if (s[i] != '0') ff = 1;
if (s[i] == '0' && !ff) f = 1;
}
else if (x < 0 || x > 255 || (x != 0 && f)) return 0;
else f = 0, x = 0, ff = 0;
}
if (x < 0 || x > 65535 || (x != 0 && f)) return 0;
if (m != 1 || d != 3) return 0;
return 1;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
// freopen("network3.in", "r", stdin);
// freopen("qwq.out", "w", stdout);
cin >> n;
while (n--){
cin >> op >> ad; ++m;
if (!check(ad)){
cout << "ERR\n";
continue;
}
if (op[0] == 'S'){
if (ss[ad] == 0){
ss[ad] = m;
cout << "OK\n";
} else cout << "FALL\n";
} else{
if (ss[ad] == 0) cout << "FALL\n";
else cout << ss[ad] << endl;
}
}
return 0;
}