import java.util.* val sc = Scanner(System.`in`) val n = sc.nextInt() val A = Array(n) { 0 } val B = Array(n) { 0 } val C = Array(n) { arrayOf(0, 0) } fun main(args: Array) { for (i in 0 until n) { A[i] = sc.nextInt() B[i] = sc.nextInt() C[i] = arrayOf(A[i], B[i]) } C.sortWith(compareBy { it[0].toDouble() / it[1] }) C.reverse() for (v in C) { println("${v[0]} ${v[1]}") } }