#include #include #include using namespace std; class Kazuate{ int A, B, C, D, N; string R; int check[10]; public: Kazuate() :A(0), B(0), C(0), D(0), N(0), R("NONE") { for (int i = 0; i < 10; i++) check[i] = 0; } Kazuate(const Kazuate& t) { A = t.A; B = t.B; C = t.C; D = t.D; N = t.N; R = t.R; } int getA(){ return A; } int getB(){ return B; } int getC(){ return C; } int getD(){ return D; } int getN(){ return N; } string getR(){ return R; } void setData() { cin >> A >> B >> C >> D >> R; } void checker() { if (R == "NO"){ for (int i = 0; i < 10; i++){ if (i == A || i == B || i == C || i == D) check[i]++; } } else if (R == "YES"){ for (int i = 0; i < 10; i++){ if (!(i == A || i == B || i == C || i == D)) check[i]++; } } } void LoopFrame() { cin >> N; for (int i = 0; i < N; i++){ setData(); checker(); } } void putAnswer() { for (int i = 0; i < 10; i++){ if (check[i] == 0){ cout << i << endl; break; } } } }; int main() { Kazuate x; x.LoopFrame(); x.putAnswer(); }