#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <complex>

using namespace std;

typedef long long ll;

#define MAXN 600000

const int G = 3, MOD = 998244353;

int L;
int R[MAXN + 10];

int n;
int fac[MAXN + 10], inv[MAXN + 10];

int qpow(int a,int b){
	int ans = 1;
	for (; b; b >>= 1,a = 1ll * a * a % MOD)
		if (b & 1) ans = 1ll * ans * a % MOD;
	return ans;
}

void ntt(int a[], int len, int f){
	for (int i = 0; i < len; i++) if (i < R[i]) swap(a[i],a[R[i]]);
	for (int i = 1; i < len; i <<= 1){
		int gn = qpow(G, (MOD - 1) / (i << 1));
		for (int j = 0; j < len; j += (i << 1)){
			int g = 1;
			for (int k = 0; k < i; k++, g = 1ll * g * gn % MOD){
				int x = a[j + k],y = 1ll * g * a[j + k + i] % MOD;
				a[j + k] = (x + y) % MOD; a[j + k + i] = (x - y + MOD) % MOD;
			}
		}
	}
	if(f == 1) return;
	int nv = qpow(len, MOD - 2); reverse(a + 1, a + len);
	for(int i = 0; i < len; i++) a[i] = 1ll * a[i] * nv % MOD;
}

void NTT(int len, int A[], int B[], int C[]) {
    ntt(A, len, 1);
    ntt(B, len, 1);
    for(int i = 0;i < len; i++) C[i] = 1ll * A[i] * B[i] % MOD;
    ntt(C, len, -1);
}

void init(int up) {
    fac[0] = inv[0] = 1;
    for(int i = 1;i <= up; i++) fac[i] = (1ll * fac[i - 1] * i) % MOD;
    inv[up] = qpow(fac[up], MOD - 2);
    for(int i = up - 1;i >= 1; i--) inv[i] = (1ll * inv[i + 1] * (i + 1)) % MOD;
}

int get_C(int a, int b) {
    if(a < 0 || b < 0 || a > b) return 0;
    return ((1ll * fac[b] * inv[a]) % MOD * inv[b - a]) % MOD;
}


int A[MAXN], B[MAXN],C[MAXN];

int main(){
	scanf("%d", &n);
    A[0] = 1;
    int tot = 0;
    init(600000);
    for(int i = 0;i < n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        int ntot = tot + a - b;
        int p = 2 * tot + ntot;
        int len;
        L = 0;
        for(len = 1;len <= p; len <<= 1) L++;
        for(int i = 0;i < len; i++) R[i] = (R[i >> 1] >> 1) | ((i & 1) << (L - 1));
        for(int i = 0;i < len; i++) B[i] = 0;
        for(int i = -tot;i <= ntot; i++) B[tot + i] = get_C(b + i, a + b);
        // for(int i = 0;i < len; i++) printf("%d ", A[i]);
        // puts("");
        // for(int i = 0;i < len; i++) printf("%d ", B[i]);
        // puts("");
	    ntt(A, len, 1); ntt(B, len, 1);
        for(int i = 0;i < len; i++) A[i] = 1ll * A[i] * B[i] % MOD;
        ntt(A, len, -1);
        // for(int i = 0;i < len; i++) printf("%d ", A[i]);
        // puts("");
        for(int i = 0;i <= ntot; i++) A[i] = A[i + tot];
        for(int i = ntot + 1;i < len; i++) A[i] = 0;
        tot = ntot;
    }
    int ans = 0;
	for (int i = 0; i <= tot; i++) ans = (ans + A[i]) % MOD;
    printf("%d\n", ans);
	return 0;
}