MOD = 10**9+7 def repeatedSquaring(n, p): if p == 0: return 1 if p % 2 == 0: t = repeatedSquaring(n, p / 2) return t * t % MOD return n * repeatedSquaring(n, p - 1) % MOD def mul(a,b): c = [[0]*len(b[0]) for i in range(len(a))] for i in range(len(a)): for k in range(len(b)): for j in range(len(b[0])): c[i][j]=(c[i][j]+a[i][k]*b[k][j]) % MOD return c def pows(a,n): b =[ [0] * len(a) for i in range(len(a))] for i in range(len(a)): b[i][i] = 1 #aを2乗していき、nの2進数表記が1の箇所のみを掛け合わせせていく while n > 0: if n & 1 == 1: #nの1の位が0のとき b = mul(a,b) a = mul(a,a) n = n>> 1 return b n = int(input()) A = [[1,1],[1,0]] ans = 1 for i in range(n): c, d = map(int, input().split()) t = pows(A,c+2)[1][0] ans = ans * repeatedSquaring(t, d) % MOD print(ans)