fun main() { val (a, b) = System.`in`.bufferedReader().lineSequence().drop(1).take(2) .map { line -> line.split(" ").map { it.toLong() } } .zipWithNext().first() val aCount = a.sumOf { aVal -> b.count { aVal > it } } val bCount = b.sumOf { bVal -> a.count { bVal > it } } println( when { aCount == bCount -> "tie" aCount > bCount -> "first" else -> "second" } ) }