#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using vc = vector<T>; template <class T> using vvc = vector<vc<T>>; template <class T> using vvvc = vector<vvc<T>>; template <class T> using vvvvc = vector<vvvc<T>>; template <class T> using vvvvvc = vector<vvvvc<T>>; #define vv(type, name, h, w) vector<vector<type>> name(h, vector<type>(w, type(0))) #define vvv(type, name, h, w, l) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(l, type(0)))) #define vvvv(type, name, a, b, c, d) vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(d, type(0))))) #define elif else if #define FOR1(a) for (ll _ = 0; _ < ll(a); _++) #define FOR2(i,n) for (ll i = 0; i < ll(n); i++) #define FOR3(i,l,r) for (ll i = l; i < ll(r); i++) #define FOR4(i,l,r,c) for (ll i = l; i < ll(r); i += (c)) #define FOR1_R(a) for (ll _ = ll(a) - 1; _ >= 0; _--) #define FOR2_R(i,n) for (ll i = (n) - 1; i >= ll(0); i--) #define FOR3_R(i,l,r) for (ll i = (r) - 1; i >= ll(l); i--) #define FOR4_R(i,l,r,c) for (ll i = (r) - 1; i >= ll(l); i -= (c)) #define overload4(a, b, c, d, e, ...) e #define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__) #define FOR_R(...) overload4(__VA_ARGS__, FOR4_R, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__) #define FOR_in(a, A) for (auto a: A) #define FOR_each(a, A) for (auto &&a: A) #define FOR_subset(t,s) for(ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s))) #define all(x) x.begin(), x.end() #define len(x) ll(x.size()) int popcnt(int x) { return __builtin_popcount(x); } int popcnt(uint32_t x) { return __builtin_popcount(x); } int popcnt(long long x) { return __builtin_popcountll(x); } int popcnt(uint64_t x) { return __builtin_popcountll(x); } int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); } int topbit(uint32_t x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); } int topbit(long long x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); } int topbit(uint64_t x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); } // ε ₯ε void rd() {} void rd(char& c) { cin >> c; } void rd(string& s) { cin >> s; } void rd(int& x) { cin >> x; } void rd(uint32_t& x) { cin >> x; } void rd(long long& x) { cin >> x; } void rd(uint64_t& x) { cin >> x; } template<class T> void rd(vector<T> & v) { for (auto& x:v) rd(x); } void read() {} template <class H, class... T> void read(H& h, T&... t) { rd(h), read(t...); } #define CHAR(...) \ char __VA_ARGS__; \ read(__VA_ARGS__) #define STRING(...) \ string __VA_ARGS__; \ read(__VA_ARGS__) #define INT(...) \ int __VA_ARGS__; \ read(__VA_ARGS__) #define U32(...) \ uint32_t __VA_ARGS__; \ read(__VA_ARGS__) #define LL(...) \ long long __VA_ARGS__; \ read(__VA_ARGS__) #define U64(...) \ uint64_t __VA_ARGS__; \ read(__VA_ARGS__) #define VC(t, a, n) \ vector<t> a(n); \ read(a) #define VVC(t, a, h, w) \ vector<vector<t>> a(h, vector<t>(w)); \ read(a) //εΊε void wt() {} void wt(const char c) { cout << c; } void wt(const string s) { cout << s; } void wt(int x) { cout << x; } void wt(uint32_t x) { cout << x; } void wt(long long x) { cout << x; } void wt(uint64_t x) { cout << x; } template<class T> void wt(const vector<T> v){ int n = v.size(); for (int i = 0; i < n; i++){ if (i) wt(' '); wt(v[i]); } } void print() { wt('\n'); } template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { wt(head); if (sizeof...(Tail)) wt(' '); print(forward<Tail>(tail)...); } template <int mod> struct modint { static constexpr uint32_t umod = uint32_t(mod); static_assert(umod < (uint32_t(1) << 31)); uint32_t val; static modint raw(uint32_t v) { modint x; x.val = v % mod; return x; } constexpr modint() : val(0) {} constexpr modint(uint32_t x) : val(x % umod) {} constexpr modint(uint64_t x) : val(x % umod) {} constexpr modint(unsigned __int128 x) : val(x % umod) {} constexpr modint(int x) : val((x %= mod) < 0 ? x + mod : x) {}; constexpr modint(long long x) : val((x %= mod) < 0 ? x + mod : x) {}; constexpr modint(__int128 x) : val((x %= mod) < 0 ? x + mod : x) {}; bool operator<(const modint &other) const { return val < other.val; } modint &operator+=(const modint &p) { if ((val += p.val) >= umod) val -= umod; return *this; } modint &operator-=(const modint &p) { if ((val += umod - p.val) >= umod) val -= umod; return *this; } modint &operator*=(const modint &p) { val = uint64_t(val) * p.val % umod; return *this; } modint &operator/=(const modint &p) { *this *= p.inverse(); return *this; } modint operator-() const { return modint::raw(val ? mod - val : uint32_t(0)); } modint operator+(const modint &p) const { return modint(*this) += p; } modint operator-(const modint &p) const { return modint(*this) -= p; } modint operator*(const modint &p) const { return modint(*this) *= p; } modint operator/(const modint &p) const { return modint(*this) /= p; } bool operator==(const modint &p) const { return val == p.val; } bool operator!=(const modint &p) const { return val != p.val; } modint inverse() const { int a = val, b = mod, s = 1, t = 0; while (1) { if (a == 1) return modint(s); t -= (b / a) * s; b %= a; if (b == 1) return modint(t + mod); s -= (a / b) * t; a %= b; } } modint pow(long long n) const { assert(n >= 0); modint res(1), a(val); while (n > 0) { if (n & 1) res *= a; a *= a; n >>= 1; } return res; } static constexpr int get_mod() { return mod; } static constexpr pair<int,int> ntt_info() { if (mod == 167772161) return {25,17}; if (mod == 469762049) return {26,30}; if (mod == 754974721) return {24,362}; if (mod == 880803841) return {23,211}; if (mod == 998244353) return {23,31}; return {-1, -1}; } }; template <int mod> void rd(modint<mod>& x) { uint32_t y; cin >> y; x = y; } template <int mod> void wt(modint<mod> x){ wt(x.val); } template <typename mint> mint fact(long long n) { static vector<mint> res = {1, 1}; static long long le = 1; while (le <= n){ le++; res.push_back(res[le - 1] * le); } return res[n]; } template <typename mint> mint fact_inv(long long n) { static vector<mint> res = {1, 1}; static long long le = 1; while (le <= n){ le++; res.push_back(res[le - 1] / le); } return res[n]; } using mint = modint<998244353>; int main() { INT(K); int S = 0; mint ans = mint(1); FOR(K) { INT(L, M); mint res = fact<mint>(L).pow(M); ans *= fact<mint>(L).pow(M).inverse(); ans *= fact<mint>(M).inverse(); S += L * M; } ans *= fact<mint>(S); print(ans); }