import sys input = sys.stdin.readline def Matprod(A, B, mod, N): temp = [0] * N*N for i in range(N): for j in range(N): ij = i * N + j for k in range(N): temp[ij] += A[i*N+k] * B[k*N+j] temp[ij] %= mod return temp def Matpow_Linear(A, M, mod, N): Mat = [0] * N*N for i in range(N): Mat[i*N+i] = 1 while M: if M & 1: Mat = Matprod(Mat, A, mod, N) A = Matprod(A, A, mod, N) M >>= 1 return Mat N = int(input()) ans = 1 mod = 10 ** 9 + 7 for i in range(N): C, D = map(int, input().split()) M = [1, 1, 1, 0] M = Matpow_Linear(M, C + 1, mod, 2) D %= mod - 1 ans *= pow(M[0], D + mod - 1, mod) ans %= mod print(ans)