// @EXPECTED_RESULTS@: TIME_LIMIT_EXCEEDED, WRONG_ANSWER fun main() { val (n,k) = readln().split(" ").map { it.toInt() } val rankings = System.`in`.bufferedReader().lineSequence().take(k).map { line-> line.split(" ").map { it.toInt() }.withIndex().sortedBy { it.value } }.toList() rankings.withIndex().minBy{ (index, current) -> // `minBy` requires Kotlin 1.7 rankings.filterIndexed { i, _-> i !=index } .sumOf { other -> current.zip(other).map { (a,b) -> (a.index - b.index) }.sumOf { it*it } } }.value.sortedBy { it.index }.map { it.value }.joinToString(separator = " ").also { println(it) } }