#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n, a, b, small_sum;
vector<P> bars;

P max_p(P a, P b){
    if(double(a.first)/a.second > double(b.first) / b.second)return a;
    else return b;
    int a_integer = a.first / a.second;
    int b_integer = b.first / b.second;
    if(a_integer > b_integer)return a;
    if(a_integer < b_integer)return b;
    a.first %= a.second;
    b.first %= b.second;
    cout << a.first << " " << a.second << " " << b.first << " " << b.second << endl;
    if(a.first * b.second > a.second * b.first)return a;
    else return b;
}

P ans = P(0, 1);

Int gcd(Int a, Int b){
    if(a == 0)return b;
    return gcd(b % a, a);
}


P prime(P x){
    a = x.first;
    b = x.second;
    Int g = gcd(a, b);
    return P(a/g,b/g);
}


void clean_up(multiset<Int> &small, multiset<Int> &big){
    if(small.empty() || big.empty())return;
    while(true){
        Int small_big = *small.rbegin();
        Int big_small = *big.begin();
        if(small_big <= big_small)break;
        small.erase(prev(small.end()));
        big.erase(big.begin());
        small.insert(big_small);
        big.insert(small_big);        
        small_sum += big_small - small_big;
    }
}

int main(){
    cin >> n;
    Int difsum = 0;
    vector<Int> as;

    for(Int i = 0;i < n;i++){
        cin >> a >> b;
        bars.push_back(P(b,a));
        difsum += max(0ll, b-a);
    }
    sort(bars.begin(), bars.end());
    Int whole = 0;
    multiset<Int> small, big;

    for(Int i = 0;i < n;i++){
        Int b = bars[i].first, a = bars[i].second;
        if(b-a < 0)difsum += b-a;
        while(true){
            if(big.empty())break;
            auto it = big.begin();
            if(difsum < *it + small_sum)break;
            whole++;
            small_sum += *it;small.insert(*it);
            big.erase(it);
        }
        Int bottom = difsum - small_sum;
        Int top = b - bottom;
     
        if(bottom >= 0 && top >= 0){
            ans = max_p(ans, P(whole*(bottom+top)+bottom,n*(bottom + top)));
//            cout << b << " " << a << " " <<  difsum << " " << small_sum << " " << whole<< endl;          
        }
        
        difsum -= b-a;
        big.insert(a);        
        clean_up(small, big);
    }
    ans = prime(ans);
    cout << ans.first << " " << ans.second << endl;
    return 0;
}