#include using namespace std; int main() { int n, temp; cin >> n; vector a(n); vector b(n); vector ans(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; ans[i] = a[i] / b[i]; } for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { if (ans[j] > ans[i]) { temp = ans[j]; ans[j] = ans[i]; ans[i] = temp; temp = a[j]; a[j] = a[i]; a[i] = temp; temp = b[j]; b[j] = b[i]; b[i] = temp; } } } for (int i = 0; i < n; i++) { cout << a[i] << " " << b[i] << endl; } return 0; }