#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<deque>
#include<map>
#include<stdio.h>
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	vector<pair<double,int>> pa(n);
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
		double temp=(double)a[i]/(double)b[i];
		//cout << temp << endl;
		pa[i].first=temp;
		pa[i].second=i;
	}
	sort(pa.begin(),pa.end());
	for(int i=n-1;i>=0;i--){
		cout << a[pa[i].second] << " " << b[pa[i].second] << endl;
	}
	return 0;
}