#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int mod = 998244353;

const int maxn = 17000;
int fac[202020], ifac[202020];
int x[maxn], f[maxn], g[maxn];


int C(int n, int k) {
    if (k < 0 || k > n || n < 0) return 0;
    return fac[n] * (ll)ifac[k] % mod * (ll)ifac[n-k] % mod;
}

const int G = 3;

inline int add(int a, int b) { return a+b>=mod?a+b-mod:a+b; }
inline void inc(int&a, int b) { if ((a+=b)>=mod) a-=mod; }
inline int sub(int a, int b) { return a-b<0?a-b+mod:a-b; }
inline void dec(int&a, int b) { if ((a-=b)<0) a+=mod; }
inline int mul(int a, int b) { return (ll)a*b%mod; }
inline int qpow(int x, int n) { int ans=1; for ( ; n; n>>=1, x=(ll)x*x%mod) if (n&1) ans=(ll)ans*x%mod; return ans; }
//-------------------------------NTT--------------------------------
int wn[30],iwn[30]; //wn[i] = G^((P-1)/(2^i)) (mod P), iwn[i] = wn[i]^(-1) (mod P)
inline void init() {
    wn[21] = qpow(G, (mod-1)/(1<<21));
    for (int i=20; i>=0; i--) wn[i] = mul(wn[i+1], wn[i+1]);
    iwn[21] = qpow(wn[21], (1<<21)-1);
    for (int i=20; i>=0; i--) iwn[i] = mul(iwn[i+1], iwn[i+1]);
}
inline void revbin_permute(int a[], int n) {
    int i=1, j=n>>1, k;
    for ( ; i<n-1; i++) {
        if (i < j) swap(a[i], a[j]);
        for (k=n>>1; j>=k; ) { j -= k; k >>= 1; }
        if (j < k) j += k;
    }
}
void NTT(int f[], int ldn, int is) {
    int n = (1<<ldn);
    revbin_permute(f, n);
    for (int i=0; i<n; i+=2) {
        int tmp1 = f[i], tmp2 = f[i+1];
        f[i] = add(tmp1, tmp2), f[i+1] = sub(tmp1, tmp2);
    }
    for (int ldm=2; ldm<=ldn; ldm++) {
        int m = (1<<ldm), mh = (m>>1);
        int dw = is>0?wn[ldm]:iwn[ldm], w = 1;
        for (int j=0; j<mh; j++) {
            for (int r=0; r<n; r+=m) {
                int u = f[r+j], v = mul(f[r+j+mh], w);
                f[r+j] = add(u, v);
                f[r+j+mh] = sub(u, v);
            }
            w = mul(w, dw);
        }
    }
}
void convolution(int f[], int g[], int n) {
    int ldn; for (int i=20; i>=0; i--) if (n&(1<<i)) { ldn=i; break; }
    NTT(f, ldn, 1); NTT(g, ldn, 1); //会改变g
    for (int i=0; i<n; i++) f[i] = mul(f[i], g[i]);
    NTT(f, ldn, -1);
    int iv = qpow(n, mod-2);
    for (int i=0; i<n; i++) f[i] = mul(f[i], iv);
}

int main(void) {
    //freopen("g.in", "r", stdin);

    int N = 200002;
    fac[0]=1; for (int i=1; i<=N; i++) fac[i]=fac[i-1]*(ll)i%mod;
    ifac[N]=qpow(fac[N], mod-2); for (int i=N-1; i>=0; i--) ifac[i]=ifac[i+1]*(ll)(i+1)%mod;

    init();

    int n; scanf("%d", &n);

    int cur_len = 1;
    x[0] = 1;

    for (int i=0; i<n; i++) {
        int a, b; scanf("%d%d", &a, &b);

        int nex_len = cur_len + a - b;

        int tot_len = cur_len + nex_len - 1;
        int L = 2; while (L <= cur_len + tot_len) L <<= 1;

//        for (int j=0; j<L; j++) f[j] = g[j] = 0;
        for (int j=0; j<cur_len; j++) f[j] = x[j];
        for (int j=cur_len; j<L; j++) f[j] = 0;
        for (int j=0; j<tot_len; j++) {
            g[j] = C(a + b, a + cur_len-1 - j);
        }
        for (int j=tot_len; j<L; j++) g[j] = 0;

//        for (int j=0; j<tot_len; j++) printf("%d ", g[j]); puts("");

        convolution(f, g, L);

        for (int j=cur_len-1; j<cur_len-1+nex_len; j++) x[j-cur_len+1] = f[j];
        cur_len = nex_len;

//        printf("i = %d, a = %d, b = %d\n", i, a, b);
//        for (int j=0; j<cur_len; j++) printf("%d ", x[j]); puts("");
    }

    int ans = 0;
    for (int i=0; i<cur_len; i++) {
        ans = (ans + x[i]) % mod;
    }
    printf("%d\n", ans);

    return 0;
}
