#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace atcoder; using ll = long long; using mint = modint1000000007; #define rep(i, n) for (int i = 0; i < n; i++) #define endl '\n' #define print(n) cout << (n) << endl void chmax(ll &a, ll b) { if (a < b) a = b; } void chmin(ll &a, ll b) { if (a > b) a = b; } int main() { int n; cin >> n; vector> a(n); rep(i, n) { vector b(5); rep(j, 4) cin >> b[j]; string t; cin >> t; b[4] = t[0] == 'N'; a[i] = b; } for (int ans = 1; ans < 10; ans++) { bool yes = true; for (auto t : a) { bool to = t[4]; rep(j, 4) to ^= t[j] == ans; yes &= to; } if (yes) { print(ans); return 0; } } return 1; }