import std.stdio, std.conv, std.string, std.range, std.algorithm, core.bitop; void main() { auto N = readln.strip.to!int; int[] A, B, C, D; string[] R; foreach (_; 0 .. N) { auto input = readln.split; A ~= input[0].to!int; B ~= input[1].to!int; C ~= input[2].to!int; D ~= input[3].to!int; R ~= input[4]; } ulong ans = 0xFFFF; foreach (i; 0 .. N) { auto flg = (1UL << A[i]) | (1UL << B[i]) | (1UL << C[i]) | (1UL << D[i]); if (R[i] == "YES") ans &= flg; else ans &= ~flg; } ans.bsf.writeln; }