//inlclude前用define #define _USE_MATH_DEFINES //include #include #include #include #include #include using namespace std; //typedef typedef vector VI; typedef vector VS; typedef vector VC; int main() { int num; VI y(10), n(10); cin >> num; int a, b, c, d,cnt=0,memo; string r; for (int i = 0; i < num; i++) { cin >> a >> b >> c >> d >> r; cnt = 0; memo = 0; if (r == "NO") { n[a]++; n[b]++; n[c]++; n[d]++; for (int j = 0; j < 10; j++) { if (n[j] == 0) { cnt++; memo = j; } } if (cnt == 1) cout << memo << endl; } else if(r=="YES"){ y[a]++; y[b]++; y[c]++; y[d]++; for (int j = 0; j < 10; j++) { if (y[j] >= 2) { cout << j << endl; } } } } return 0; }