#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1e6 + 50;
const ll mod = 998244353;

int n, ans, cnt = 1;
int jc[N], jc_inv[N];
ll f[N], g[N];

ll qpow(ll a, ll b, int mod){
    ll t = 1;
    while(b){
        if(b & 1)  t = (t *a) % mod;
        b >>= 1;
        a = (a * a) % mod;
    }
    return t;
}

void NTT(int n, ll *a, int opt){
    int i, j = 0, k;
    for(i = 0; i < n; i++){
        if(i > j)  swap(a[i], a[j]);
        for(int l = n >> 1; (j ^= l) < l; l >>= 1);
    }
    for(i = 1; i < n; i <<= 1){
        ll wn = qpow(3, (mod - 1) / (i << 1), mod);
        int m = i << 1;
        for(j = 0; j < n; j += m){
            ll w = 1;
            for(k = 0; k < i; k++, w = (w * wn) % mod){
                ll z = (a[j + i + k] * w) % mod;
                a[i + j + k] =( a[j+ k] - z + mod) % mod;
                a[j + k] = (a[j + k] + z) % mod;
            }
        }
    } 
    if(opt == -1)  reverse(a + 1, a + n);
}

// 注意多次使用的话要初始化，将数组值清零，注意n和m的意义 
// a数组储存最后结果，n,m分别是a,b的项数，数组下标从0开始 
int work(ll *a, int n, ll *b, int m){
	int fn = 1;
    while(fn <= n + m)  fn <<= 1;
    NTT(fn, a, 1);  NTT(fn, b, 1);
    // 这里a数组储存结果，所以是a[i] = (a[i] * b[i]) % mod
    // 如果是算其他形式多项式相乘，如(2 - a[x] * b[x]) * b[x]的多项式相乘
    // 那么要改为a[i] = ((2 - a[i] * b[i]) % mod * b[i] % mod + mod) % mod 
    for(int i = 0; i <= fn; i++)  a[i] = (a[i] * b[i]) % mod;
    // 对储存结果的数组NTT
    NTT(fn, a, -1);
    ll t = qpow(fn, mod - 2, mod);
    for(int i = 0; i < fn; i++)  a[i] = (a[i] * t) % mod;
	return fn;
}

int main(){
    scanf("%d", &n);
    jc[0] = 1;
    for(int i = 1; i < N; ++i)  jc[i] = 1LL * jc[i - 1] * i % mod;
    jc_inv[N - 1] = qpow(jc[N - 1], mod - 2, mod);
    for(int i = N - 2; ~i; --i)  jc_inv[i] = 1LL * jc_inv[i + 1] * (i + 1) % mod;
    f[1] = 1;
    while(n--){
        int a, b, tot = -1;
        scanf("%d%d", &a, &b);
        int max_j = a - b + cnt,  max_k = cnt;
        int p = 1e9;
        for(int i = 1 - max_k; i <= max_j - 1; ++i){
            if(a - i >= 0 && b + i >= 0){
                if(p == 1e9)  p = i;
                g[++tot] = 1LL * jc_inv[a - i] * jc_inv[b + i] % mod;
            	//printf("hh %lld\n", g[tot]);
			}
        }
        int len = work(f, cnt, g, tot);
        //for(int i = 0; i <= cnt + tot; ++i)  printf("hh  %lld\n", f[i]);
        for(int i = 0; i < len; ++i)  f[i] = f[i] * jc[a + b] % mod;
        int tt = -1;
        for(int i = 0; i < len; ++i){
            if(p >= 0 && p <= max_j)  f[++tt] = f[i];
            ++p;  
        }
        for(int i = tt + 1; i < len; ++i)  f[i] = 0;
        f[0] = 0,  cnt = tt;
        //for(int i = 0; i <= cnt; ++i) printf("hh %lld\n", f[i]);
        for(int i = 0; i < len; ++i)  g[i] = 0;
    }
    for(int i = 1; i <= cnt; ++i)  ans = (ans + f[i]) % mod;
    printf("%d", ans);  
    return 0;
}