l = int(input()) mod = 10**9+7 ans = 1 for i in range(l): p, e = map(int, input().split()) x = (1-pow(p, e+1, mod))*pow(1-p, mod-2, mod) y = p*(1-pow(p, e, mod))*pow(1-p, mod-2, mod)-e*pow(p, e+1, mod) y *= pow(1-p, mod-2, mod) ans *= (1+e)*x-y ans %= mod print(ans)