#include #include #include #include using namespace std; bool comp(const pair &a, const pair &b) { return a.first * b.second > a.second * b.first; } int main() { size_t n; cin >> n; vector> frac(n); for (size_t i = 0; i < n; ++i) cin >> frac[i].first >> frac[i].second; sort(frac.begin(), frac.end(), comp); for (size_t i = 0; i < n; ++i) cout << frac[i].first << ' ' << frac[i].second << endl; }