// @EXPECTED_RESULTS@: TIME_LIMIT_EXCEEDED, WRONG_ANSWER import kotlin.math.max fun main() { val (n, r) = readln().split(" ").map { it.toInt() } val minScore = .5 * r * n * (3 * n + 1) val ranking = System.`in`.bufferedReader().lineSequence().take(r).map { line -> line.split(" ").map { it.toInt() } }.toList() // optimal ranking for a conest if ordered by score // (2n, 1), (2n-1, 2), ..., (2n -i, i+1), ... (n+1, n) // Only consider optimal pairs for a contest val options = ranking.distinct() .map { order -> val ranks = order.withIndex().sortedBy { it.value } (0 until n).map { ranks[it].index to ranks[2 * n - it - 1].index } } options .map { option -> ranking.sumOf { ranks -> option.sumOf { (a, b) -> max(ranks[a], ranks[b]) } } } .firstOrNull { it >= minScore }?.also { println("possible") } ?: println("impossible") }