#include typedef long long i64; using std::cout; using std::endl; using std::cin; struct tapu { int a, b; tapu(int a, int b) : a(a), b(b) {} bool operator<(const tapu r) { return b * r.a < a * r.b; } }; int main() { int n; cin >> n; std::vector vec; for(int i = 0; i < n; i++) { int a, b; cin >> a >> b; vec.push_back(tapu(a, b)); } sort(begin(vec), end(vec)); for(auto v : vec) cout << v.a << " " << v.b << endl; return 0; }