n = gets.to_i answer = (0..9).to_a taro_reply = [] n.times do |i| taro_reply[i] = gets.split taro_reply[i][0..3] = taro_reply[i][0..3].map(&:to_i) if taro_reply[i][4] == "NO" 0.upto(3) do |j| answer[taro_reply[i][j]] = "x" end else 0.upto(9) do |k| if !taro_reply[i].include?(k) answer[k] = "x" end end end end answer.each do |i| p i if i != "x" end