#include #include #include using namespace std; using i64 = long long; using mat = i64[2][2]; class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x0; n>>=1) { if(n & 1) { matmul(R, A, R); } matmul(A, A, A); } memcpy(res, R, sizeof(R)); } i64 bigint2modint(string bignum, i64 mod) { i64 res = 0; for(char c : bignum) { (res *= 10) += (c - '0'); res %= mod; } return res ? res : mod-1; } i64 mod_pow(i64 a, i64 n, i64 mod) { i64 res = 1LL; for(i64 p=a, x=n; x>0; x>>=1) { if(x & 1) { (res *= p) %= mod; } (p *= p) %= mod; } return res; } int main(void) { int n; scanf("%d", &n); i64 res = 1; for(int i : range(n)) { i64 c; char d[210]; scanf("%lld%s", &c, d); mat ma = {{1, 1}, {1, 0}}; mat powered; matpow(ma, c+1, powered); i64 dd = bigint2modint(d, mod-1); (res *= mod_pow(powered[0][0], dd, mod)) %= mod; } printf("%d\n", int(res)); return 0; }