import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from operator import itemgetter mod=998244353 F=[1] for i in range(1,200020): F.append(F[-1]*i%mod) # 高速ベキ乗 def fast_pow(x,y): ANS=1 while y>0: if y%2==1: ANS=ANS*x%mod y-=1 if y>0: x=x*x%mod y//=2 return ANS N=int(input()) LIST=[list(map(int,input().split())) for i in range(N)] Q=[] for b,c in LIST: Q.append((b,c-b+1,1)) Q.append((c+1,c-b+1,2)) Q.sort(key=itemgetter(1)) Q.sort(key=itemgetter(0)) now1=0 ANS1=0 for i in range(len(Q)): x,length,com=Q[i] LINV=fast_pow(length,mod-2) if com==1: now1=(now1+LINV)%mod ANS1=(ANS1-LINV)%mod else: now1=(now1-LINV)%mod if i+1