#include #include #include using namespace std; int main() { int n; vector> yv; vector nv; cin >> n >> std::ws; for (int i = 0; i < n; i++) { string tmps; vector v; for (int j = 0; j < 5; j++) { cin >> tmps >> std::ws; if (tmps == "YES") { yv.push_back(v); } else if (tmps == "NO") { for (int k = 0; k < v.size(); k++){ nv.push_back(v[k]); } } else { v.push_back(stoi(tmps)); } } } vector base; for (int l = 0; l < 10; l++) { base.push_back(l); } vector nnums; for (int m = 0; m < base.size(); m++) { int is_match = 0; for (int o = 0; o < nv.size(); o++) { if (base[m] == nv[o]) { is_match = 1; } } if (is_match == 0) { nnums.push_back(base[m]); } } if (nnums.size() != 1){ for (int p = 0; p < yv.size(); p++) { vector tmpv; for (int q = 0; q < nnums.size(); q++) { for (int r = 0; r < yv[p].size(); r++) { if (nnums[q] == yv[p][r]) { tmpv.push_back(nnums[q]); } } } nnums = tmpv; } } cout << nnums[0] << endl; return 0; }