#include #include #include #define repeat(i,n) for (int i = 0; (i) < (n); ++(i)) #define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i)) typedef long long ll; using namespace std; const int mod = 1e9+7; int fib(ll n) { static unordered_map memo; if (memo.count(n)) return memo[n]; if (n == 0 or n== 1) return memo[n] = 1; ll a = n/2, b = (n+1)/2; return memo[n] = (fib(a)*(ll)fib(b) + fib(a-1)*(ll)fib(b-1)) % mod; } int powi(int x, string const & d) { ll y = 1; int n = d.size(); repeat_reverse (i,n) { int c = d[i] - '0'; ll z = 1; repeat (j,10) { if (j == c) y = y * z % mod; z = z * x % mod; } x = z; } return y; } int main() { int n; cin >> n; ll ans = 1; repeat (i,n) { ll c; string d; cin >> c >> d; ans = ans * powi(fib(c+1), d) % mod; } cout << ans << endl; return 0; }