#include using namespace std; int main() { int n; cin >> n; vector> d( n ); for( int i = 0; i < n; i++ ) { int A, B; cin >> A >> B; d[i] = make_tuple( (double)A / B, A, B ); } sort( d.begin(), d.end(), greater>() ); for( int i = 0; i < n; i++ ) { cout << get<1>( d[i] ) << " " << get<2>( d[i] ) << endl; } }