n = gets.chomp.to_i as = (0..9).to_a n.times do a, b, c, d, r = gets.chomp.split.map { |x| x.length == 1 ? x.to_i : x } if r == 'YES' as &= [a, b, c, d] else as -= [a, b, c, d] end end puts as[0]