// Arup Guha
// 6/15/2023
// Solution to CSES Problem: Divisor Analysis
// https://cses.fi/problemset/task/2182

using namespace std;
#include <bits/stdc++.h>
typedef long long ll;

const ll MOD = 1000000007ll;

ll modpow(ll b, ll e, ll m);
ll modinv(ll a, ll n);
vector<ll> modinvrec(ll a, ll n);

int main() {

    // Set up accumulators...
    int n;
    ll numD = 1, sumD = 1, myNum = 1;
    ll numDDiffMod = 1;
    cin >> n;

    ll sqrt = 1;
    bool pSq = true;

    // Go through each term.
    for (int i=0; i<n; i++) {

        // Get term update # divisors.
        ll base, exp;
        cin >> base >> exp;
        if (exp%2 == 1) pSq = false;
        if (pSq) sqrt = (sqrt*modpow(base,exp/2, MOD))%MOD;

        // Calculate # of divisors under two mods.
        numD = (numD*(exp+1))%MOD;
        numDDiffMod = (numDDiffMod*(exp+1))%(2*MOD-2);

        // Update the number itself.
        myNum = (myNum* modpow(base,exp,MOD))%MOD;

        // Term in sum formula. Subtract 1 from it.
        ll term = modpow(base, exp+1, MOD);
        term = (term - 1 + MOD)%MOD;

        // This is what we "divide" by.
        ll inv = modinv(base-1, MOD);

        // This is the full sum under mod.
        term = (term*inv)%MOD;

        // Update sum of divisors.
        sumD = (sumD*term)%MOD;
    }

    // We need this mod for the exponent for squares.
    ll save = numDDiffMod;

    // This is the exponent for non-squares.
    numDDiffMod /= 2;

    // Update the product of divisors depending on whether it's a square or not.
    ll prod = 1;
    if (!pSq)
        prod = modpow(myNum, numDDiffMod, MOD);
    else
        prod = modpow(sqrt, save, MOD);

    // Ta da!
    cout << numD << " "<< sumD << " " << prod << endl;
    return 0;
}

// Return b raised to the power e mod m.
ll modpow(ll b, ll e, ll m) {

    // Base case.
    if (e == 0) return 1%m;

    // Savings are here. Raise to e/2 power and then square.
    if (e%2 == 0) {
        ll tmp = modpow(b, e/2, m);
        return (tmp*tmp)%m;
    }

    // Usual breakdown.
    return (b*modpow(b,e-1,m))%m;
}

// Wrapper function, returns a^-1 mod n.
ll modinv(ll a, ll n) {
	vector<ll> res = modinvrec(a, n);
	return res[1] >= 0 ? res[1] : res[1] + n;
}

// returns [x,y] such that nx + ay = 1.
vector<ll> modinvrec(ll a, ll n) {
	if (a == 1) return vector<ll>{0,1};
	vector<ll> res = modinvrec(n%a, a);
	return vector<ll>{res[1], res[0]-res[1]*(n/a)};
}
