#!/usr/bin/python mod = int(1e9) + 7 def matmul(A, B): res = [[0, 0], [0, 0]] res[0][0] = (A[0][0]*B[0][0] + A[0][1]*B[1][0]) % mod res[0][1] = (A[0][0]*B[0][1] + A[0][1]*B[1][1]) % mod res[1][0] = (A[1][0]*B[0][0] + A[1][1]*B[1][0]) % mod res[1][1] = (A[1][0]*B[0][1] + A[1][1]*B[1][1]) % mod return res def matpow(A, n): res = [[1, 0], [0, 1]] while n > 0: if n & 1: res = matmul(res, A) A = matmul(A, A) n >>= 1 return res n = int(raw_input()) res = 1 for i in xrange(n): c, d = map(int, raw_input().split()) x = matpow([[1, 1], [1, 0]], c+1)[0][0] if d > mod - 1: d %= (mod - 1) res = res * pow(x, d, mod) % mod print res