#include using namespace std; #define _p(...) (void)printf(__VA_ARGS__) #define forr(x,arr) for(auto&& x:arr) #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) _rep3(i,0,n) #define _rep3(i,a,b) for(int i=int(a);i=int(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__) #define ALL(x) (x).begin(), (x).end() #define BIT(n) (1LL<<(n)) #define SZ(x) ((int)(x).size()) #define fst first #define snd second typedef vector vi;typedef vector vvi;typedef pair pii;typedef vector vpii; typedef long long ll; const long long mod = 1000000007; template struct Mint { int x; Mint() : x(0) {} Mint(int y) : x(y >= 0 ? y % MOD : MOD - (-y) % MOD) {} Mint(signed long long sll) : x(sll % MOD) { if (x < 0) x += MOD; } Mint &operator+=(const Mint &rhs){ if((x += rhs.x) >= MOD) x -= MOD; return *this; } Mint &operator-=(const Mint &rhs){ if((x += MOD - rhs.x) >= MOD) x -= MOD; return *this; } Mint &operator*=(const Mint &rhs){ x = 1LL*x*rhs.x % MOD; return *this; } Mint &operator/=(const Mint &rhs){ x = (1LL*x*rhs.inv().x) % MOD; return *this; } Mint operator-() const { return Mint(-x); } Mint operator+(const Mint &rhs) const { return Mint(*this) += rhs; } Mint operator-(const Mint &rhs) const { return Mint(*this) -= rhs; } Mint operator*(const Mint &rhs) const { return Mint(*this) *= rhs; } Mint operator/(const Mint &rhs) const { return Mint(*this) /= rhs; } bool operator<(const Mint &rhs) const { return x < rhs.x; } Mint inv() const { signed a = x, b = MOD, u = 1, v = 0, t; while(b){ t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } return Mint(u); } Mint operator^(unsigned long long t) const { Mint e = *this, res = 1; for(; t; e *= e, t>>=1) if (t & 1) res *= e; return res; } Mint operator^(const string& y) const { Mint x = *this, res = 1; for (char c : y) { int b = c - '0'; res = res ^ 10; res *= (x ^ b); } return res; } }; template ostream &operator<<(ostream &os, const Mint &rhs) { return os << rhs.x; } template istream &operator>>(istream &is, Mint &rhs) { long long s; is >> s; rhs = Mint(s); return is; }; using mint = Mint; typedef vector Vec; typedef vector Mat; Mat matMul(const Mat &l, const Mat &r) { int nrow = (int) l.size(); int ncol = (int) r[0].size(); int x = (int) r.size(); Mat ret(nrow, Vec(ncol)); for (int i = 0; i < nrow; i++) { for (int k = 0; k < x; k++) { for (int j = 0; j < ncol; j++) { ret[i][j] += l[i][k] * r[k][j]; } } } return ret; } Mat matPow(Mat A, long long m) { int size = A.size(); Mat B(size, Vec(size, 0)); for (int i = 0; i < size; i++) B[i][i] = 1; while (m > 0) { if (m & 1) B = matMul(B, A); A = matMul(A, A); m >>= 1; } return B; } void Main() { int N; cin >> N; Mat a{{1,1},{1,0}}; mint ans = 1; rep(i,N) { ll c; string d; cin >> c >> d; Mat b = matPow(a, c+1); mint pat = b[0][0]; ans *= pat ^ d; } cout << ans << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }