const val NO = "NO" fun main(args: Array) { val turns = readLine()!!.toInt() var remains = (1..9).toSet() for (i in 1..turns) { val line = readLine()!!.split(" ") val nums = line.take(4).map(String::toInt) if (line.last() == NO) { remains -= nums } else { remains = remains.intersect(nums) } if (remains.size == 1) { remains.forEach(::println) return } } }