#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v, w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int INF = INT_MAX / 2; vector< vector > matmul(vector< vector >& A, vector< vector >& B) { int n = A.size(); vector< vector > C(n, vector(n)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++) C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD; return C; } vector< vector > matpow(vector< vector > A, ll x) { int n = A.size(); vector< vector > B(n, vector(n)); for (int i = 0; i < n; i++) B[i][i] = 1; while (x > 0) { if (x % 2) B = matmul(B, A); x /= 2; A = matmul(A, A); } return B; } int pow_mod(ll x, ll n, int m) { ll res = 1; for (; n > 0; n >>= 1) { if (n & 1) res = (res * x) % m; x = (x * x) % m; } return res; } int main() { vector< vector > a(2, vector(2)); a[0][0] = 1; a[0][1] = 1; a[1][0] = 1; a[1][1] = 0; vector b(202); b[0] = 1; for (int i = 1; i <= 201; i++) b[i] = b[i - 1] * 10 % MOD; int N; cin >> N; ll sum = 1; while (N--) { ll C; string D; cin >> C >> D; ll x = matpow(a, C + 1)[0][0] % MOD; ll y = 0; for (int i = 0; i < D.length(); i++) y += b[D.length() - i - 1] * (D[i] - '0'); y %= MOD; ll z = pow_mod(x, y, MOD - 1); sum = sum * z % MOD; } cout << sum << endl; }