n = int(input()) mod = 1000000007 def matrixmod(matrix): for i in range(2): for j in range(2): matrix[i][j] %= mod return matrix def matrixmul(a, b): res = [[0, 0], [0, 0]] for i in range(2): for j in range(2): for k in range(2): res[i][j] += a[i][k] * b[k][j] return res def powmatrix(matrix, p): if p == 0: return [[1, 0], [0, 1]] elif p % 2 == 1: return matrixmod(matrixmul(matrix, powmatrix(matrix, p - 1))) else: res = powmatrix(matrix, p / 2) return matrixmod(matrixmul(res, res)) matrix = [[1, 1], [1, 0]] ans = 1 for i in range(n): c, d = map(int, input().split()) res = powmatrix(matrix, c + 1)[0][0] ans *= pow(res, d, mod) ans %= mod print(ans)