import java.io.*; import java.util.*; public class Main_yukicoder750 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); List nu = new ArrayList<>(n); List de = new ArrayList<>(n); for (int i = 0; i < n; i++) { int a = sc.nextInt(); int b = sc.nextInt(); nu.add(a); de.add(b); for (int j = nu.size() - 1; j > 0; j--) { int pa = nu.get(j - 1); int pb = de.get(j - 1); if (pa * b < a * pb) { Collections.swap(nu, j, j - 1); Collections.swap(de, j, j - 1); } else { break; } } } for (int i = 0; i < n; i++) { pr.printf("%d %d%n", nu.get(i), de.get(i)); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }