def f(c, d, mod, memo): return pow(g(c, mod, memo), d, mod) def g(c, mod, memo): p, q = 1, 1 i = 0 while c: if c & 1: a, b = memo[i] tmp = p - q p = (a*q + b*tmp) % mod q = (a*tmp - b*(tmp - q)) % mod c >>= 1 i += 1 return p def preprocess(c, mod): a, b = 2, 1 memo = [(2, 1)] while c: t = a - b t *= t a *= a a -= t a %= mod b *= b b += t b %= mod c >>= 1 memo.append((a, b)) return memo def solve(): mod = 10**9 + 7 memo = preprocess(10**18, mod) N = int(input()) ans = 1 for n in range(N): c, d = map(int, input().split()) ans *= f(c, d, mod, memo) ans %= mod return ans print(solve())