#include <bits/stdc++.h> using namespace std; using i64 = int64_t; using vi = vector<i64>; using vvi = vector<vi>; int main() { using ii = pair<int, int>; using pp = pair<double, ii>; vector<pp> vs; int n; cin >> n; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; vs.push_back(pp(double(a) / b, ii(a, b))); } sort(vs.begin(), vs.end(), greater<>()); for (int i = 0; i < n; i++) { cout << vs[i].second.first << " " << vs[i].second.second << endl; } }