fun main(args: Array) { val n = readLine()!!.toInt() val num = (1..n).map { readLine()!!.split(" ").map { it.toInt() }.let { Num(it[0], it[1]) } }.sortedDescending() num.forEach { println("${it.a} ${it.b}") } } class Num(val a:Int, val b:Int):Comparable { override fun compareTo(other: Num): Int { if(b == other.b) { return a.compareTo(other.a) } return (a*other.b).compareTo(other.a*b) } }