#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using base = ll;//complex<double>;
const ll mod = 998244353;
ll mexp(ll x, ll y) {
    ll r = 1;
    for(;y;x=x*x%mod, y>>=1) if(y & 1) r = r * x % mod;
    return r;
}
ll modd(ll x) {
    if(x >= mod) x -= mod;
    if(x < 0) x += mod;
    return x;
}
void fft(vector<base>& a, bool inv) {
    int n = a.size(), j = 0;
    vector<base> roots(n/2);
    for(int i=1;i<n;i++) {
        int bit = (n >> 1);
        while(j >= bit) {
            j -= bit;
            bit >>= 1;
        }
        j += bit;
        if(i < j) swap(a[i], a[j]);
    }
    // In NTT, let prr = primitive root. Then,
    int prr = 3;
    ll ang = mexp(prr, (mod - 1) / n);
    if(inv) ang = mexp(ang, mod - 2);
    for(int i=0; i<n/2; i++){
        roots[i] = (i ? (1ll * roots[i-1] * ang % mod) : 1);
    }
    //also, make sure to apply modulus under here
    for(int i=2;i<=n;i<<=1) {
        int step = n / i;
        for(int j=0;j<n;j+=i) {
            for(int k=0;k<i/2;k++) {
                base u = a[j+k], v = a[j+k+i/2] * roots[step * k] % mod;
                a[j+k] = modd(u+v);
                a[j+k+i/2] = modd(u-v+mod);
            }
        }
    }
    if(inv) for(int i=0;i<n;i++) a[i] = a[i] * mexp(n, mod-2) % mod;
}
void conv(vector<base>& x, vector<base>& y) {
    int n = 2; while(n < x.size()+y.size()) n <<= 1;
    x.resize(n), y.resize(n);
    fft(x, false); fft(y, false);
    for(int i=0;i<n;i++) x[i] = x[i] * y[i] % mod;
    fft(x, true);
}
const int lim = 222222;
ll f[lim], fi[lim];
vector<base> ans, mul, nans;
int n;
ll binom(int a, int b) {
    if(b < 0 || b > a) return 0;
    return f[a] * fi[b] % mod * fi[a-b] % mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    ans.reserve(1<<16);
    mul.reserve(1<<16);
    f[0] = 1;
    for(int i=1;i<lim;i++)
        f[i] = i * f[i-1] % mod;
    fi[lim-1] = mexp(f[lim-1], mod-2);
    for(int i=lim-2;i>=0;i--)
        fi[i] = (i+1) * fi[i+1] % mod;
    ans.push_back(1);
    for(int i=0;i<n;i++) {
        int a, b;
        cin >> a >> b;
        int m = ans.size();
        int m1 = 2 * m + a - b - 1;
        for(int j=0;j<m1;j++)
            mul.emplace_back(binom(a+b, b+j-(m-1)));
        conv(ans, mul);
        nans.clear(); nans.resize(m+a-b);
        for(int i=0;i<m+a-b;i++) nans[i] = ans[m-1+i];
        ans = nans;
        mul.clear();
    }
    cout << accumulate(ans.begin(), ans.end(), 0LL) % mod;
}