#include using namespace std; int main() { int N, A[10][4], R[10] = {}; cin >> N; for (int i = 0; i < N; i++) { for (int j = 0; j < 4; j++) { cin >> A[i][j]; } string s; cin >> s; if (s == "YES") R[i] = 1; } for (int i = 0; i < 10; i++) { bool flag = true; for (int j = 0; j < N; j++) { int tmp = 0; for (int k = 0; k < 4; k++) { if (A[j][k] == i) tmp = 1; } if (tmp != R[j]) flag = false; } if (flag) { cout << i << endl; return 0; } } }