#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using PLL = pair<LL, LL>;
constexpr int maxn = 120000;
void out(LL a, LL b){
    if(a == 0) cout << 0 << " " << 1;
    else{
        LL d = __gcd(a, b);
        cout << a / d << " " << b / d;
    }
    exit(0);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<PLL> v;
    LL rm = 0;
    for(int i = 1, A, B; i <= n; i += 1){
        cin >> A >> B;
        if(B >= A) v.push_back({B, 1});
        else v.push_back({A, 0});
        rm += max(B - A, 0);
    }
    sort(v.begin(), v.end());
    int k = -1;
    for(int i = 0; i < n; i += 1){
        if(rm < v[i].first) break;
        else rm -= v[i].first, k = i;
    }
    int j = k + 1;
    while(v[j].second == 0) j += 1;    
    if(k == -1 or v[k].second == 0) out((k + 1) * v[j].first + rm, v[j].first * n);
    LL A = rm, B = v[j].first;
    int f = k;
    while(f < n and v[f].second == 1) f += 1;
    if(f == n) out((k + 1) * v[j].first + rm, v[j].first * n);
    LL a = rm + v[k].first - v[f].first, b = v[k].first;
    if(A * b <= a * B) out((k + 1) * b + a, b * b );
    else out((k + 1) * v[j].first + rm, v[j].first * n);
    return 0;
}