import std.algorithm, std.array, std.range; import std.string, std.conv; import std.stdio, std.typecons; void main() { auto n = readln.chomp.to!int; auto pi = iota(n).map!((s) { const t = readln.split; auto u = t[0..4].map!(to!int).array; u.sort; return tuple(u, t[4]); }); auto i = iota(9).map!(e => e + 1).array; auto r = reduce!((a, p) { if (p[1] == "YES") { return setIntersection(a, p[0]).array; } else { return setDifference(a, p[0]).array; } })(i, pi); writeln(r[0]); }