#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n'
#define all(v) (v).begin(), (v).end()
template<class A, class B> ostream& operator<<(ostream& os, const pair<A,B>& p) {
	return os << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream& os, T&& x) -> decltype(x.begin(), os) {
	os << '{';
	for(auto it = x.begin(); it != x.end(); ++it) os << *it << (it == prev(x.end()) ? "" : ", ");
	return os << '}';
}
void dump() {}
template<class T,class... Args> void dump(T&& x,Args... args) { cerr<<x<<";  "; dump(args...); }
#ifdef DEBUG
    struct Lf{ ~Lf() { cerr << '\n'; } };
    #define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Lf(), cerr << ""
#else
    #define debug(...) 0&&cerr
#endif

const int MAX = 1<<23;		//max input vector length
const int MOD = 998244353;	//prime modulus e.g. 998244353 = 1 + 7*17*2^23
const int G = 3;			//generator for Z_MOD
 
int modpow(int base, int exp) {
  base %= MOD;
  int result = 1;
  while (exp > 0) {
	if (exp & 1) result = (1ll*result * base) % MOD;
	base = (1ll*base * base) % MOD;
	exp >>= 1;
  }
  return result;
}
int modinv(int a) {
    return modpow(a,MOD-2);
}
//FFT=1 for transform, FFT=-1 for inverse transform; N=current input length, should use a power of 2
void fft(vector<int>& a, int FFT, int N) {
    static int rev[MAX];
    for (int i = 0; i < N; i++) {
		rev[i] = (rev[i>>1]>>1)|((i&1)?(N>>1):0);
        if (i < rev[i]) swap(a[i], a[rev[i]]);
    }
    for (int m = 2, m2 = 1; m <= N; m <<= 1, m2 <<= 1) {
        int wm = modpow(G, (MOD-1)/m*FFT+(FFT==-1?MOD-1:0));
        for (int k = 0; k < N; k += m)
            for (int j = 0, u, t, w = 1; j < m2; j++)
                t = 1ll*w*a[k+j+m2]%MOD, u = a[k+j], w = 1ll*w*wm%MOD,
                a[k+j] = (u+t)%MOD, a[k+j+m2] = (u-t+MOD)%MOD;
    }
    if (FFT == -1)
        for (int i = 0, invN = modinv(N); i < N; i++)
            a[i] = 1ll * a[i] * invN % MOD;
}
 
int degp,degq;
vector<int> P,Q;

void mul() {
    int N=1;
	for (; N<degp+degq+1; N<<=1);
	while ((int)P.size()<N) P.push_back(0);
	while ((int)Q.size()<N) Q.push_back(0);
	
	fft(P,1,N);
	fft(Q,1,N);
	for (int i=0; i<N; ++i) P[i] = (1ll*P[i]*Q[i])%MOD;
	fft(P,-1,N);
	while (P.back()==0) P.pop_back();
}

int n, a,b, fact[200010], ifact[200010];
void calc() {
    fact[0] = 1, fact[1] = 1, ifact[0] = 1, ifact[1] = 1;
    for (int i=2; i<=200000; ++i) {
        fact[i] = (1ll*fact[i-1]*i) % MOD;
        ifact[i] = modinv(fact[i]);
    }
}
int C(int x, int y) {
    if (y<0 || y>x) return 0;
    int div = (1ll*ifact[y]*ifact[x-y])%MOD;
    return (1ll*fact[x]*div)%MOD;
}

int main() {
    ios::sync_with_stdio(false);
    calc();
    cin >> n;
    P = {1};
    for (int i=0; i<n; ++i) {
        cin >> a >> b;
        int m = P.size();
        Q.clear();
        for (int j=b-m+1; j<m+a; ++j) Q.push_back(C(a+b,j));
        degp = m-1;
        degq = Q.size()-1;
        mul();
        for (int j=0; j<m+a-b; ++j) P[j] = P[m+j-1];
        P.resize(m+a-b);
    }
    int sum = 0;
    for (int x : P) {
        sum = (sum+x) % MOD;
    }
    cout << sum << endl;

	return 0;
}
