import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[][] x = new long[n][2]; for (int i = 0; i < n; ++i) { x[i][0] = sc.nextLong(); x[i][1] = sc.nextLong(); } Arrays.sort(x, new Comparator() { @Override public int compare(long[] o1, long[] o2) { return Double.compare((double) o1[0] / o1[1], (double) o2[0] / o2[1]); } }); for (int i = n - 1; i >= 0; --i) { System.out.println(x[i][0] + " " + x[i][1]); } } static long gcd(long a, long b) { if (a > b) return gcd(b, a); if (a == 0) return b; return gcd(b % a, a); } public static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }