use std::{ collections::HashSet, io::{self, BufRead}, }; fn main() { let input = io::stdin() .lock() .lines() .map(|l| { l.unwrap() .split(' ') .map(std::string::ToString::to_string) .collect::>() }) .collect::>(); let mut possible = (0..=9).collect::>(); input[1..].iter().for_each(|l| { let numbers = l[..4] .iter() .map(|n| n.parse::().unwrap()) .collect::>(); if l[4] == "YES" { possible.retain(|n| numbers.contains(n)); } else { possible.retain(|n| !numbers.contains(n)); } }); println!("{}", possible.iter().next().unwrap()); }