#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; struct Fraction { int numerator; int denominator; }; bool sortFraction(Fraction f1, Fraction f2) { return f1.numerator * f2.denominator < f1.denominator * f2.numerator; } int main() { int N; cin >> N; vector vs; for (int i = 0; i < N; ++i) { int A, B; cin >> A >> B; Fraction f = {.numerator=A, .denominator=B}; vs.push_back(f); } sort(vs.begin(),vs.end(),sortFraction); reverse(vs.begin(),vs.end()); for (int i = 0; i < N; ++i) { cout << vs[i].numerator << " " << vs[i].denominator << endl; } return 0; }