import sys #input = sys.stdin.readline #文字列につけてはダメ input = sys.stdin.buffer.readline #文字列につけてはダメ #sys.setrecursionlimit(1000000) #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush #from collections import defaultdict #from collections import deque #import copy #import math #from functools import lru_cache #@lru_cache(maxsize=None) MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] def main(): L = int(input()) ans = 1 for i in range(L): p,e = map(int,input().split()) inv = pow(1-p,MOD-2,MOD) #print(inv) x = e+1 - p*(1 - pow(p,e,MOD)) * inv - pow(p,e+1,MOD) #print(e+1, p*(1 - pow(p,e,MOD)), pow(p,e+1)) x %= MOD #print(x) x *= inv ans *= x%MOD ans %= MOD print(ans) if __name__ == '__main__': main()