import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Num[] nums = new Num[n]; for (int i = 0; i < n; i++) { nums[i] = new Num(sc.nextInt(), sc.nextInt()); } Arrays.sort(nums); StringBuilder sb = new StringBuilder(); for (Num x : nums) { sb.append(x).append("\n"); } System.out.print(sb); } static class Num implements Comparable { int child; int mother; public Num(int child, int mother) { this.child = child; this.mother = mother; } public int compareTo(Num another) { return another.child * mother - child * another.mother; } public String toString() { return child + " " + mother; } } }