#include using namespace std; struct s { int A, B; }; int compare(const void *x, const void *y) { return ((s*)x)->B * ((s*)y)->A - ((s*)x)->A * ((s*)y)->B; } int main() { int n; cin >> n; s frac[n]; for (int i = 0; i < n; ++i) cin >> frac[i].A >> frac[i].B; qsort(frac, n, sizeof(s), compare); for (int i = 0; i < n; ++i) cout << frac[i].A << ' ' << frac[i].B << endl; }