#include<bits/stdc++.h>
#define go(i,a,b) for(int i=a;i< b;i++)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int X=2e5,N=33e3,mo=998244353;
int fac[X+9],ivf[X+9],n,a,b,m=1,m1,n1,f[2][N],g[N],ans;
void P(int&x,ll y) {x=(x+y)%mo;}
void T(int&x,ll y) {x=x*y%mo;}
int ksm(int x,int y=mo-2) {int a=1; for(;y;y/=2,T(x,x)) if(y&1)T(a,x); return a;}
int C(int n,int m) {return m>=0&&m<=n?1ll*fac[n]*ivf[m]%mo*ivf[n-m]%mo:0;}
namespace NTT
{
	int tf[N],w[N],o;
	void build(int n)
	{
		o=__builtin_ctz(n);
		go(i,1,n) tf[i]=tf[i/2]+n*(i&1)>>1;
		for(int i=1;i<n;i*=2)
		{
			int v=ksm(3,(mo-1)/2/i); w[i]=1;
			go(j,1,i) w[i+j]=1ll*w[i+j-1]*v%mo;
		}
	}
	void DFT(int a[N],int n,bool f)
	{
		static unsigned long long b[N];
		int u=o-__builtin_ctz(n),v;
		go(i,0,n) b[i]=a[tf[i]>>u];
		for(int i=1;i<n;i*=2) for(int j=0;j<n;j+=2*i) go(k,0,i)
			v=b[i+j+k]*w[i+k]%mo, b[i+j+k]=b[j+k]-v+mo, b[j+k]+=v;
		go(i,0,n) a[i]=b[i]%mo;
		if(f)
		{
			reverse(a+1,a+n);
			v=mo-(mo-1)/n;
			go(i,0,n) T(a[i],v);
		}
	}
	void mtp(int a[N],int b[N],int n)
	{
		DFT(a,n,0); DFT(b,n,0);
		go(i,0,n) T(a[i],b[i]);
		DFT(a,n,1);
	}
}
int main()
{
	fac[0]=1;
	fo(i,1,X) fac[i]=1ll*fac[i-1]*i%mo;
	ivf[X]=ksm(fac[X]);
	fd(i,X,1) ivf[i-1]=1ll*ivf[i]*i%mo;
	NTT::build(32768);
	scanf("%d",&n); f[0][1]=1;
	fo(i,1,n)
	{
		scanf("%d%d",&a,&b); m1=m+a-b;
		int I=i&1;
		for(n1=1;n1/2<=m+m1+1;n1*=2);
		memset(g,0,4*n1);
		fo(j,0,m+m1) g[j]=C(a+b,b+j-m);
		NTT::mtp(g,f[!I],n1);
		memset(f[!I],0,4*n1);
		fo(j,1,m+a-b) f[I][j]=g[j+m];
		m=m1;
	}
	fo(i,1,m) P(ans,f[n&1][i]);
	printf("%d",ans);
}
  	