#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main(){ int i, j, k; int n; vector>y(0, vector(4)); vector>no(0, vector(4)); vectorflag(10, false); vectorflag2(11, 0); cin >> n; for (i = 0; i < n; i++) { int n1, n2, n3, n4; string s; cin >> n1 >> n2 >> n3 >> n4 >> s; if (s == "YES") { y.push_back({ n1,n2,n3,n4 }); } else if (s == "NO") { no.push_back({ n1,n2,n3,n4 }); } } for (i = 0; i < no.size(); i++) { flag[no[i][0]] = true; flag[no[i][1]] = true; flag[no[i][2]] = true; flag[no[i][3]] = true; } int cnt = 0; int index = 0; for (i = 0; i < 10; i++) { if (flag[i] == false) { cnt++; index = i; } } if (cnt == 1) { cout << index << endl; getchar(); getchar(); return 0; } for (i = 0; i < y.size(); i++) { if (flag[y[i][0]] == false)flag2[y[i][0]]++; if (flag[y[i][1]] == false)flag2[y[i][1]]++; if (flag[y[i][2]] == false)flag2[y[i][2]]++; if (flag[y[i][3]] == false)flag2[y[i][3]]++; } for (i = 0; i < 11; i++) { if (flag2[i] >= 2) { cout << i << endl; break; } } getchar(); getchar(); return 0; }