#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
#define N 200015
const int p=998244353;
int n,a,b,f[N],finv[N],inv[N],rev[N],ta[N],tb[N];
inline int C(int nn,int mm){if(nn<mm||nn<0||mm<0)return 0;return 1ll*f[nn]*finv[mm]%p*finv[nn-mm]%p;}
inline int ksm(int d,int k){int ret=1;while(k){if(k&1)ret=1ll*ret*d%p;d=1ll*d*d%p;k>>=1;}return ret;}
inline void ntt(int x[],int len,int mde)
{for(int i=0;i<len;i++)if(i<rev[i])swap(x[i],x[rev[i]]);
	for(int i=2;i<=len;i<<=1)
	{int wn=ksm(3,(p-1)/i);if(mde<0)wn=ksm(wn,p-2);
		for(int j=0,stp=i>>1;j<len;j+=i)for(int k=j,w=1;k<j+stp;k++,w=1ll*w*wn%p)
		{int t1=x[k],t2=1ll*x[k+stp]*w%p;
			x[k]=(t1+t2)%p,x[k+stp]=(t1-t2+p)%p;
		}
	}if(mde<0)for(int i=0,te=ksm(len,p-2);i<len;i++)x[i]=1ll*x[i]*te%p;
}
int main()
{
	scanf("%d",&n);int len=1;f[0]=finv[0]=f[1]=finv[1]=inv[1]=1;
	for(int i=2;i<=200000;i++)
	{
		inv[i]=1ll*(p-p/i)*inv[p%i]%p;
		f[i]=1ll*f[i-1]*i%p;finv[i]=1ll*finv[i-1]*inv[i]%p;
	}ta[1]=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a,&b);
		int nl=max(len,len+a-b),tle=1;
		while(tle<=(nl*3))tle<<=1;
		for(int j=1;j<tle;j++){rev[j]=rev[j>>1]>>1;if(j&1)rev[j]|=tle>>1;}
		for(int j=len+1;j<tle;j++)ta[j]=0;for(int j=0;j<tle;j++)tb[j]=0;
		for(int j=-len;j<=nl;j++)tb[len+j]=C(a+b,b+j);
		ntt(ta,tle,1);ntt(tb,tle,1);for(int j=0;j<tle;j++)ta[j]=1ll*ta[j]*tb[j]%p;ntt(ta,tle,-1);
		for(int j=1;j<=len+a-b;j++)ta[j]=ta[j+len];
		for(int j=len+a-b+1;j<tle;j++)ta[j]=0;len+=a-b;
	}int ans=0;for(int i=1;i<=len;i++)(ans+=ta[i])%=p;printf("%d\n",ans);
}

