#include #include using namespace std; int main() { bool x[10] = { false }; int check[6] = { 0 }; int num[6][4]; string str[6]; int N; cin >> N; for (int i = 0; i < N; i++) { for (int j = 0; j < 4; j++) { cin >> num[i][j]; } cin >> str[i]; } for (int i = 0; i < N; i++) { if (str[i] == "NO") { for (int j = 0; j < 4;j++) { if(x[num[i][j]] != true) x[num[i][j]] = true; } } else { for (int j = 0; j < 10;j++) { int count = 0; for (int k = 0;k < 4; k++) { if (num[i][k] == j) { count++; } } if (count == 0) { x[j] = true; } } } } for (int i = 0;i < 10;i++) { if (x[i] == false) { cout << i << endl; return 0; } } return 0; }