#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
map < string, int > vis;
bool check(string s)
{
int len = s.size(), c = 0, t = 0, f = 0;
for(int i = 0; i < len; i++)
{
if(s[i] == 0 && t == 0 && i != f) return 0;
if(s[i] >= '0' && s[i] <= '9') t = t * 10 + (s[i] - '0');
else
{
if(s[i] == '-') t *= -1;
else
{
c++;
if(c == 4)
{
if(s[i] != ':') return 0;
}
else if(s[i] != '.') return 0;
if(t > 255 || t < 0) return 0;
t = 0;
f = i + 1;
}
}
}
if(t > 65535 || t < 0) return 0;
return 1;
}
int main()
{
int t;
cin >> t;
for(int i = 1; i <= t; i++)
{
string op, s;
cin >> op >> s;
if(check(s) == 0)
{
cout << "ERR" << endl;
continue;
}
if(op == "Server")
{
if(vis[s] == 0)
{
vis[s] = i;
cout << "OK" << endl;
}
else cout << "FAIL" << endl;
}
else
{
if(vis[s] == 0) cout << "FAIL" << endl;
else cout << vis[s] << endl;
}
}
return 0;
}
WA in #13,14,17,18,19,20,21