#include #include #include #include using namespace std; int main(void) { int num, i = 0, j, k; cin >> num; string s; vector ans(10, 0), qs(5, 100); for (; i < num; i++) { scanf("%d%d%d%d", &qs[0], &qs[1], &qs[2], &qs[3]); cin >> s; sort(qs.begin(), qs.end()); if (s == "YES") { for (j = 0, k = 0; j < 10; j++) { if (ans[j] == 2) continue; if (j == qs[k]) { ans[j] = 1; k++; } else ans[j] = 2; } } else { for (j = 0; j < 4; j++) ans[qs[j]] = 2; } } for (i = 0; i < 10; i++) { if (ans[i] != 2) cout << i << "\n"; } return 0; }