#include<bits/stdc++.h>
#define int long long
using namespace std;
map<string ,int> mp;
int n;
int pos;
int genint(string s,char c)
{
if(pos>=s.size())return -1;
if(s[pos]<'0'||s[pos]>'9')
{
return -1;
}
if(pos+1<=s.size()-1&&s[pos]=='0'&&s[pos+1]>='0'&&s[pos+1]<='9')
{
return -1;
}
int res=0;
for(;pos<s.size();pos++)
{
if(s[pos]>='0'&&s[pos]<='9')
{
res=res*10+(s[pos]-'0');
}
else if(s[pos]==c)
{
pos++;
return res;
}
else
{
return 1e9;
}
}
}bool check(string s)
{
pos=0;
int num1=genint(s,'.');
int num2=genint(s,'.');
int num3=genint(s,'.');
int num4=genint(s,':');
int num5=genint(s,'#');
if(num1<0||num1>255||num2<0||num2>255||num3<0||num3>255||num4<0||num4>255||num5<0||num5>65536)
{
return 0;
}
return 1;
}
signed main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
string op,ad;
cin>>op>>ad;
if(op=="Server")
{
if(check(ad)==0)
{
cout<<"ERR"<<endl;
}
else if(mp[ad]==0)
{
cout<<"OK"<<endl;
}
else cout<<"FAIL"<<endl;
}
else
{
if(check(ad)==0)
{
cout<<"ERR"<<endl;
}
else if(mp[ad]==0)
{
cout<<"FAIL"<<endl;
}
else cout<<mp[ad]<<endl;
}
}
return 0;
}
求调QAQ