#include #include #include #define REP(i,a,b) for(int i = (a); i < (b); i++) #define rep(i,a) REP(i,0,a) using namespace std; typedef long long ll; typedef vector vec; typedef vector mat; const int MOD = 1000000007; mat mul(mat &A, mat&B) { mat C(A.size(), vec(B[0].size())); rep(i, A.size()) { rep(k, B.size()) { rep(j, B[0].size()) { C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD; } } } return C; } mat pow(mat A, ll n) { mat B(A.size(), vec(A.size())); rep(i, A.size()) { B[i][i] = 1; } while (n > 0) { if (n & 1) B = mul(B, A); A = mul(A, A); n >>= 1; } return B; } int main(void){ int N; cin >> N; ll ans = 1; rep(loop,N) { ll C; string SD; cin >> C >> SD; mat A(2, vec(2)); A[0][0] = 1; A[0][1] = 1; A[1][0] = 1; A[1][1] = 0; A = pow(A,C+2); ll patern = A[1][0]; int D = stoi(SD)%MOD; rep(i,D) { ans = ans*patern%MOD; } } cout << ans << endl; return 0; }