#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<set>
#include<cassert>

using namespace std;

//#define int long long

using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const ll INF = (1e+18) + 100;
const ll mod = 1000000007;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repl(i, l, n) for(int i=l;i<n;++i)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

typedef long double ld;
const ld eps = 1e-8;

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	while (b) {
		ll r = a % b; a = b; b = r;
	}
	return a;
}

bool isl(pair<ll, LP> a, pair<ll, LP> b) {
	if (a.first != b.first)return a.first < b.first;
	return a.second.first*b.second.second < a.second.second*b.second.first;
}
void solve() {
	int n; cin >> n;
	vector<ll> bs;
	ll sum = 0;
	vector<LP> w;
	rep(i, n) {
		int a, b; cin >> a >> b;
		if (a <= b) {
			sum += a;
			bs.push_back(b);
		}
		else {
			w.push_back({ a,b });
		}
	}
	sort(bs.begin(), bs.end(), greater<ll>());
	vector<ll> rb(bs.size() + 1);
	rep(i, bs.size()) {
		rb[i + 1] = rb[i] + bs[i];
	}
	if (bs.size() == 0) {
		cout << "0 1" << endl; return;
	}
	sort(w.begin(), w.end());
	if (w.size() == 0) {
		//assert(false);
		int id = upper_bound(rb.begin(), rb.end(), sum) - rb.begin();
		id--;
		ll rest = sum - rb[id];
		pair<ll, LP> memo = { bs.size() - id - 1,{bs[id]-rest,bs[id]} };
		LP ans = { memo.second.first + memo.first*memo.second.second,memo.second.second };
		ans.second *= n;
		ll g = gcd(ans.first, ans.second);
		ans.first /= g; ans.second /= g;
		cout << ans.first << " " << ans.second << endl;
		return;
	}
	else if (w.size() == 1) {
		ll suma = sum;
		int id = upper_bound(rb.begin(), rb.end(), suma) - rb.begin();
		id--;
		ll rest = suma - rb[id];
		pair<ll, LP> z1 = { bs.size() - id - 1,{ bs[id]-rest,bs[id] } };
		//cout << z1.first << " " << z1.second.first<<" "<<z1.second.second << endl;
		suma = sum + w[0].first;
		pair<ll, LP> z2;
		if (suma >= rb[bs.size()] + w[0].second) {
			z2 = { 0,{ 0,1 } };
		}
		else {
			id = lower_bound(rb.begin(), rb.end(), suma - (w[0].second - 1)) - rb.begin();
			rest = suma - rb[id];
			if (rest < 0) {
				id = upper_bound(rb.begin(), rb.end(), suma) - rb.begin();
				id--;
				z2.first = 1 + bs.size() - id - 1;
				ll rest = suma - rb[id];
				z2.second = { bs[id] - rest,bs[id] };
			}
			else {
				z2.first = 1 + bs.size() - id-1;
				z2.second = { w[0].second - rest,w[0].second };
			}
		}
		LP ans;
		if (isl(z1, z2)) {
			ans = { z2.second.first + z2.first*z2.second.second,z2.second.second };
		}
		else {
			ans = { z1.second.first + z1.first*z1.second.second,z1.second.second };
		}
		ans.second *= n;
		ll g = gcd(ans.first, ans.second);
		ans.first /= g; ans.second /= g;
		cout << ans.first << " " << ans.second << endl;
		return;
	}
	ll suma = sum;
	int id = upper_bound(rb.begin(), rb.end(), suma) - rb.begin();
	id--;
	ll rest = suma - rb[id];
	pair<ll, LP> memo = { bs.size() - id - 1,{ bs[id]-rest,bs[id] } };
	vector<ll> rw(w.size() + 1);
	rep(i, w.size()) {
		rw[i + 1] = rw[i] + w[i].first;

	}
	rep(i, w.size()) {
		int le = -1, ri = w.size() - 1;
		while (ri - le > 1) {
			int m = (le + ri) / 2;
			ll suma = sum + rw[m] + w[i].first;
			if (i < m) {
				suma -= w[i].first;
				suma += w[m].first;
			}
			if (suma >= w[i].second + rb[bs.size()]) {
				ri = m-1; continue;
			}
			pair<ll, LP> c1, c2;
			id = lower_bound(rb.begin(), rb.end(), suma - (w[i].second - 1)) - rb.begin();

			rest = suma - rb[id];
			if (rest < 0) {
				id = upper_bound(rb.begin(), rb.end(), suma) - rb.begin();
				id--;
				c1.first = m + 1 + bs.size() - id - 1;
				ll rest = suma - rb[id];
				c1.second = { bs[id] - rest,bs[id] };
			}
			else {
				c1.first = m + 1 + bs.size() - id - 1;
				c1.second = { w[i].second - rest,w[i].second };
			}
			suma = sum + rw[m + 1] + w[i].first;
			if (i < m + 1) {
				suma -= w[i].first;
				suma += w[m + 1].first;
			}
			if (suma >= w[i].second + rb[bs.size()]) {
				ri = m; continue;
			}
			id = lower_bound(rb.begin(), rb.end(), suma - (w[i].second - 1)) - rb.begin();

			rest = suma - rb[id];
			if (rest < 0) {
				id = upper_bound(rb.begin(), rb.end(), suma) - rb.begin();
				id--;
				c2.first = m + 1 + 1 + bs.size() - id - 1;
				ll rest = suma - rb[id];
				c2.second = { bs[id] - rest,bs[id] };
			}
			else {
				c2.first = m + 1 + 1 + bs.size() - id - 1;
				c2.second = { w[i].second - rest,w[i].second };
			}
			if (isl(c1, c2)) {
				le = m;
			}
			else {
				ri = m;
			}
		}
		ll suma = sum + rw[ri] + w[i].first;
		if (i < ri) {
			suma -= w[i].first;
			suma += w[ri].first;
		}
		if (suma < w[i].second + rb[bs.size()]) {
			//cout << "! " << suma << endl;
			id = lower_bound(rb.begin(), rb.end(), suma - (w[i].second - 1)) - rb.begin();
			pair<ll, LP> z;

			rest = suma - rb[id];
			if (rest < 0) {
				id = upper_bound(rb.begin(), rb.end(), suma) - rb.begin();
				id--;
				z.first = ri + 1 + bs.size() - id - 1;
				ll rest = suma - rb[id];
				z.second = { bs[id] - rest,bs[id] };
			}
			else {
				z.first = ri + 1 + bs.size() - id - 1;
				z.second = { w[i].second - rest,w[i].second };
			}
			//cout << z.first << " " << z.second.first<<" "<<z.second.second << endl;
			if (isl(memo, z)) {
				memo = z;
			}
		}
		ri = 0;
		suma = sum + rw[ri] + w[i].first;
		if (i < ri) {
			suma -= w[i].first;
			suma += w[ri].first;
		}
		if (suma >= w[i].second + rb[bs.size()])continue;
		//cout << "! " << suma << endl;
		id = lower_bound(rb.begin(), rb.end(), suma - (w[i].second - 1)) - rb.begin();
		pair<ll, LP> z;

		rest = suma - rb[id];
		if (rest < 0) {
			id = upper_bound(rb.begin(), rb.end(), suma) - rb.begin();
			id--;
			z.first = ri + 1 + bs.size() - id - 1;
			ll rest = suma - rb[id];
			z.second = { bs[id] - rest,bs[id] };
		}
		else {
			z.first = ri + 1 + bs.size() - id - 1;
			z.second = { w[i].second - rest,w[i].second };
		}
		if (isl(memo, z)) {
			memo = z;
		}
	}

	LP ans = { memo.second.first + memo.first*memo.second.second,memo.second.second };
	ans.second *= n;
	ll g = gcd(ans.first, ans.second);
	ans.first /= g; ans.second /= g;
	cout << ans.first << " " << ans.second << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 2676