#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
const int N = 110;
int b[N];
struct A{
int score; // 本题的分数
int selections; // 本题选择的个数
int yes; // 本题选择正确的个数
vector<char>v; // 存储正确答案的选项
}s[N];
int getSum(string str,int index)
{
// 看看选项的个数和正确选项的个数是否一致
if(str[0]-'0'!=s[index].yes){
return 0;
}
// 判断选项是否和正确选项一样
for(int i = 0;i < s[index].yes;i++)
{
if(str[i+1]!=s[index].v[i]){
return 0;
}
}
// 返回这个题的分数
return s[index].score;
}
int main()
{
int n,m;
// 简单的输入
cin >> n >> m;
for(int i = 1;i<=m;i++)
{
// 简单的输入
cin >> s[i].score >> s[i].selections >> s[i].yes;
for(int j = 0;j < s[i].yes;j++)
{
char c;
cin >> c;
s[i].v.push_back(c);
}
}
vector<int>Score;
for(int i = 0;i < n; i++)
{
int Sum = 0;
char c;
for(int j = 1;j <= m;j++)
{
string sl;
while(true)
{
cin >> c;
if(c=='('||c==' ')
{
continue;
}
else if(c==')')
{
int t = getSum(sl,j);
if(t==0)
{
b[j]++;
}
Sum = t + Sum;
break;
}
else{
sl = sl + c;
}
}
}
// 把分数放在一个容器里
Score.push_back(Sum);
}
for_each(Score.begin(),Score.end(),[](int x){cout << x << endl;});
int Max = 0;
for(int i = 1;i <= m;i++)
{
if(b[i]>Max){
Max = b[i];
}
}
if(Max == 0)
{
cout <<"Too simple" << endl;
return 0;
}
vector<int>v1;
for(int i = 1;i <= m;i++)
{
if(b[i]==Max){
v1.push_back(i);
}
}
cout << Max <<" ";
bool tf = false;
for(auto &x : v1)
{
if(tf)cout <<" ";
tf = true;
cout << x;
}
return 0;
}