#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
typedef struct {
int score;
int right_cnt;
char right[6];
int wrong;
} question;
int main(){
int N, M, max_error = 0;
scanf("%d %d", &N, &M);
question q[M+1];
for(int i = 1; i < M + 1; i++) {
int cnt, j = 0;
scanf("%d %d %d", &q[i].score, &cnt, &q[i].right_cnt);
q[i].wrong = 0;
char c;
while ((c = getchar()) != '\n') {
if (isalpha(c)) {
q[i].right[j] = c;
j++;
}
}
q[i].right[j] = '\0';
}
for (int i = 0; i < N; i++) {
int grades = 0, cnt, j;
for (j = 1; j < M + 1; j++) {
scanf("(%d", &cnt);
int k = 0;
char c, choose[6];
while ((c = getchar()) != ')') {
if (isalpha(c)) {
choose[k] = c;
k++;
}
}
choose[k] = '\0';
if (cnt == q[j].right_cnt && strcmp(choose, q[j].right) == 0) {
grades += q[j].score;
} else {
q[j].wrong++;
}
if (max_error < q[j].wrong) {
max_error = q[j].wrong;
}
getchar();
}
printf("%d\n", grades);
}
if (max_error == 0) {
printf("Too simple");
} else {
printf("%d", max_error);
for (int i = 1; i < M + 1; i++) {
if (q[i].wrong == max_error) {
printf(" %d", i);
}
}
}
printf("\n");
return 0;
}