#include #include int main() { int n, abcd[4][6], num[10] = {}, max, i, j; char r[6][4]; scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j < 4; j++) { scanf("%d", &abcd[j][i]); } scanf("%s", &r[i]); if (strcmp(r[i], "YES") == 0) { for (j = 0; j < 4; j++) { if (num[abcd[j][i]] != -1) num[abcd[j][i]]++; } } else { for (j = 0; j < 4; j++) { num[abcd[j][i]] = -1; } } } max = num[0]; for (i = 1; i < 10; i++) { if (num[i - 1] < num[i]) max = i; } printf("%d\n", max); return 0; }