#include using namespace std; #define REP(i,m,n) for(int i = m; i < n; i++) #define rep(i,n) REP(i,0,n) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する #define PI 3.14159265359 typedef long long LL; template inline void chmax(T& a, T b) { if (a < b) { a = b; } } template inline void chmin(T& a, T b) { if (a > b) { a = b; } } template inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); } template inline T lcm(T x, T y) { return (x * y) / gcd(x, y); } template inline vector convert_to_binary_number(T x) { vector binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; } template inline void print_vector(vector vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;} const LL MOD = 1e9 + 7; const LL INF = 1LL << 60; int main(void){ int n; cin >> n; vector > irreducible_fraction(n); for (int i = 0; i < n; i++) { double real_num, a, b; cin >> a >> b; real_num = a / b; irreducible_fraction[i] = {real_num, a, b}; } sort(RALL(irreducible_fraction)); for (int i = 0; i < n; i++) { cout << get<1>(irreducible_fraction[i]) << " " << get<2>(irreducible_fraction[i]) << endl; } return 0; }