#include #include #include using namespace __gnu_pbds; using namespace std; template using oset = tree, rb_tree_tag, tree_order_statistics_node_update>; // oset Operations: order_of_key(k) -> Number of elements strictly smaller than k, find_by_order(k) -> kth element in the set #define ull unsigned long long int #define int long long int #define pb push_back #define eb emplace_back #define all(x) x.begin(),x.end() #define pii pair #define pll pair #define vi vector #define vb vector #define vd vector #define vll vector #define vpii vector #define vpll vector #define vvi vector #define vvll vector #define vvb vector #define vs vector #define pull pair #define F first #define S second #define m_p make_pair const long double PI = 3.141592653589793238462643383279502884197169399; template string to_string(pair p); template string to_string(tuple p); string to_string(const string& s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(bool b) { return (b ? "true" : "false"); } string to_string(vector v) { bool first = true; string res = "{"; for (int i = 0; i < static_cast(v.size()); i++) { if (!first) { res += ", "; } first = false; res += to_string(v[i]); } res += "}"; return res; } template string to_string(bitset v) { string res = ""; for (size_t i = 0; i < N; i++) { res.push_back(static_cast('0' + v[i])); } return res; } template string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } template string to_string(pair p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template string to_string(tuple p) { return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")"; } void debug_out() { cerr << endl; } template void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } #ifndef LOCAL #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 0 #endif // Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1)) const int mod = 1e9 + 7; long long binpow(long long a, long long b, long long m) { a %= m; long long res = 1; while (b > 0) { if (b & 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } void solve(){ int n; cin >> n; int ans = 1; for(int i = 0; i < n; i++){ int x, n; cin >> x >> n; int mul = (binpow(x, n + 1, mod) - 1 + mod) % mod; mul *= x; mul %= mod; mul *= binpow(x - 1, mod - 2, mod) % mod; mul %= mod; mul -= (n + 1); mul += mod; mul %= mod; mul *= binpow(x - 1, mod - 2, mod) % mod; mul %= mod; ans *= mul; ans %= mod; } cout << ans; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout << fixed << setprecision(10); int tt=1; // cin >> tt; while(tt--){ solve(); } }