#include <bits/stdc++.h>
using namespace std;
string ans[55], str, s[55];
int T, n;
void solved()
{
string id, now;
int sum = 0;
int ans2 = 0;
int cnt = 1;
cin >> id >> now;
int len = id.size();
for (int i = len - 1; i >= 0; i--)
{
ans2 += (id[i] - '0') * cnt;
cnt *= 2;
}
if (ans2 < 1 || ans2 > 10000)
{
cout << "Wrong ID\n";
return ;
}
cout << "ID: " << ans2 << "\n";
if ((id[15] == 1 && now[1] == 1 && now[0] == 0) || (id[15] == 0 && now[0] == 0 && now[1] == 1))
{
cout << "Type Correct\n";
}
else
{
cout << "Type Incorrect\n";
}
int tian = 0;
for (int i = 0; i < n; i++)
{
cin >> s[i];
if (s[i] == ans[i])
{
tian++;
}
}
double pre = 100 / n * tian;
cout << fixed << setprecision(1);
cout << pre << "\n";
return ;
}
int main()
{
cin >> T >> n;
cin >> str;
for (int i = 0; i < str.size(); i++)
{
ans[i] = "0000";
ans[i][str[i] - 'A'] = '1';
}
while (T--)
{
solved();
cout << "\n";
}
return 0;
}