#include "bits/stdc++.h" using namespace std; int main() { int n; cin >> n; vector A(n), B(n); vector > s(n); for (int i = 0; i < n; i++) { cin >> A[i] >> B[i]; s[i].first = A[i]*1.0 / B[i]; s[i].second = i; } sort(s.begin(),s.end()); reverse(s.begin(), s.end()); for (int i = 0; i < n; i++) { cout << A[s[i].second] <<" "<< B[s[i].second] << endl; } }