#define _USE_MATH_DEFINES #include #include #include #include #include #include //#include #include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)< ///////// typedef long long LL; typedef long double LD; ///////// using namespace::std; ///////// const int nmax = 30000; LL C[nmax]; string D[nmax]; const LL mod = (LL)1e9+7; LL powmod(LL n,LL p){ if(p==0)return 1; LL ans = 1; LL mul = n; while( p ){ if( p%2 ){ ans = (ans * mul)%mod; } p /= 2; mul = (mul * mul)%mod; } return ans; } LL invMod(LL a){ return powmod(a,mod-2); } LL conv(LL n,LL k){ if( k == 0 || k == n) return 1; if( k < 0 || n < k ) return 0; k = min(k,n-k); LL ans = 1; for(int i=k;i>0;--i){////////// ans = ( ans * ( (n-k+i) * invMod(i) ) % mod ) % mod; } return ans; } //string % (mod -1) LL powStrMod(LL n,string num){//n^num % mod LL ans = 1; LL mul = n; int keta[201]; int ketamax = num.size(); for(int i=num.size();i>0;--i){ keta[ketamax-i+1] = num[i-1]-'0'; } while( ketamax ){ if(keta[1]%2){ ans = (ans * mul)%mod; } //p /= 2; for(int i= ketamax;i>0;--i){ int ks=0; if( keta[i] % 2 ) ks = 10; keta[i] /= 2; if( i == ketamax && keta[i]==0) --ketamax; if(i>1){ keta[i-1] += ks; } } mul = (mul * mul)%mod; } return ans; } LL fmod(LL n,LL *a,LL *b){ if( n == 0){ *a = 0; *b = 1; return (*a); }else if( n == 1){ *a = 1; *b = 1; return (*a); } LL A,B; fmod(n/2,&A,&B); if(n%2 == 0){ *a = (A*((2*B)%mod+mod-A)%mod)%mod; *b = ((B*B)%mod+(A*A)%mod)%mod; }else{ *a = ((B*B)%mod+(A*A)%mod)%mod; *b = (B*((2*A)%mod+B)%mod)%mod; } return *a; } int main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;// //cout << setprecision(16);// int N; cin >> N;//机の種類 rep(i,N){ //Ck 椅子の数 D個(D乗) cin>>C[i]>>D[i]; } /////////////// LL ans,tans; LL A,B; ans = 1; rep(i,N){ //C[i] tans = fmod(C[i]+2,&A,&B); /*tans = 0; for(int j=0;j<=(1+C[i])/2;++j){ tans = ( tans + conv( C[i]+1-j, j) ) % mod; }*/ // //tans = tans^D[i] % mod; tans = powStrMod(tans,D[i]); //ans = (ans * tans)% mod; ans = (ans * tans)% mod; } P(ans); return 0; }