rt!!!
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
int n, s, i1;
int a[10], f, g, cnt = 1, b[2500010];
string op, ad;
int g1(int x)
{
int ans = 0, t = x;
while (t)
{
ans = ans * 10 + t % 10;
t /= 10;
}
return ans % 10;
}
int main()
{
scanf("%d", &n);
while (i1 < n)
{
i1 ++;
printf("%d\n", i1);
cin >> op >> ad;
s = 0, cnt = 1, f = 0, g = 0;
bool flag = 1;
for (int i = 1; i <= 10; i ++ ) a[i] = 0;
for (int i = 0; i < ad.size(); i ++ )
{
if (ad[i] >= '0' && ad[i] <='9')
{
int x = ad[i] - '0';
a[cnt] = a[cnt] * 10 + x;
}
else
{
cnt ++;
if(ad[i] == '.') f ++;
if(ad[i] == ':') g ++;
}
s += int(ad[i]) * ad[i];
}
for (int i = 1; i <= 5; i ++ )
{
if(a[i] != 0 && g1(a[i]) == 0)
{
printf("ERR\n");
flag = 0;
break;
}
}
if(flag == 0) continue;
if(cnt != 5 || f != 3 || g != 1) printf("ERR\n");
else if(a[1] > 255 || a[2] > 255 || a[3] > 255 || a[4] > 255 || a[5] > 65536) printf("ERR\n");
else
{
if(op == "Server")
{
if(b[s] == 0)
{
b[s] = i1;
printf("OK\n");
}
else
{
printf("FAIL\n");
}
}
if(op == "Client")
{
if(b[s] != 0)
{
printf("%d\n", b[s]);
}
else printf("FAIL\n");
}
}
}
return 0;
}