#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

pll OK(pll A){
	//return A;
	return pll(A.F/__gcd(A.F,A.S), A.S/__gcd(A.F, A.S));
}
pll add(pll A, pll B){
	return OK(pll(A.F*B.S + A.S*B.F, A.S*B.S));
}
pll mx(pll A, pll B){
	return (A.F * B.S >= A.S * B.F ? A : B);
}


ll l[Maxn], r[Maxn], ind[Maxn];

vector<pll> V;
vector<ll> V2;

ll ps[Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll a, b;
	ll sm = 0;
	for(int i = 0; i < n; i++){
		cin >> l[i] >> r[i];
		a=l[i];
		b=r[i];
		if(a < b){
			sm += (a - b);
			V.pb({b, i});
			V2.pb(b);
		} else {
			V.pb({a, i});
		}
	}
	
	sort(all(V));
	for(int i = 0; i < n; i++) ind[V[i].S] = i;
	ps[0] = V[0].F;
	for(int i = 1; i < n; i++) ps[i] = ps[i - 1] + V[i].F;
	//cerr << sm << '\n';
	//for(auto x : V) cerr << x.F << ' '; cerr << '\n';
	pll ans = {0, 1};
	pll A;
	ll sm2, d;
	
	ll L, R, mid, v;
	for(int i = 0; i < n; i++){
		sm2 = sm;
		
		if(l[i] < r[i]) d = r[i];
		else sm2 += (l[i] - r[i]), d = l[i];
		if(sm2 >= 0) continue;
		
		L = -1, R = n, mid;
		while(L + 1 < R){
			mid = (L + R) >> 1;
			v = ps[mid];
			if(mid >= ind[i]) v -= d;
			if(sm2 + v <= 0) L = mid;
			else R = mid;
		}
		ll C = L + 1;
		v = ps[L];
		if(L >= ind[i]) v -= d, C = L;
		ll al = -(sm2 + v);
		
		if(r[i] >= al) {
			//cerr << '\n';
			//cerr << C << '\n';
			//debug(i);
			//debug(C);
			//debug(sm2);
			//debug(al);
			//debug(r[i]);
			ans = mx(ans,  OK({al + C*r[i],n*r[i]} ) );
			//cerr << ans.F << ' ' << ans.S << '\n';
		}
	}
	ans = OK(ans);
	cout << ans.F << " " << ans.S << '\n';
	return 0;
}

