#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  pair<double, pair<int,int>> a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i].second.first >> a[i].second.second;
    a[i].first = (double)a[i].second.first / a[i].second.second;
  }
  sort(a, a + n);
  reverse(a, a + n);
  for (int i = 0; i < n; i++) {
    cout << a[i].second.first << " " << a[i].second.second << endl;
  }
  return 0;
}