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) { Pair(0, 0) } fun main(args: Array) { for (i in 0 until n) { A[i] = sc.nextInt() B[i] = sc.nextInt() C[i] = Pair(A[i], B[i]) } C.sortWith(compareByDescending { it.first.toDouble() / it.second }) for (v in C) { println("${v.first} ${v.second}") } }