#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define pb push_back #define mp make_pair #define INF ll(1e18) #define mod 998244353 #define mod2 1000000007 #define eps 1e-9 #define abs(x) ((x)>=0?(x):-(x)) #define y1 solai #define fi first #define se second typedef long long ll; typedef long double ld; typedef pair pll; typedef pair pdd; const ll N=200100; ll n,a,b,ans=1,x,y; ll bin(ll a, ll n) { ll ans=1; while(n) { if(n&1) ans*=a,ans%=mod2; a*=a,a%=mod2; n/=2; } return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; for(ll i=1;i<=n;i++) { cin>>a>>b; x=bin(a,b+2)-a*b+b-2*a+1; x=(x%mod2+mod2)%mod2; y=(a-1)*(a-1)%mod2; ans*=x*bin(y,mod2-2)%mod2; ans%=mod2; } cout<