import sys def input(): return sys.stdin.readline()[:-1] mod=998244353 N,K=map(int,input().split()) C=[list(map(int,input().split())) for _ in range(N)] ans=1 tmp=[] for i in range(N): tmp.append((C[i][0]*(10**6),0)) tmp.append((C[i][1]*(10**6)-1,1)) tmp.sort() tmp2=K for i in range(2*N): if tmp[i][1]==0: ans*=tmp2 ans%=mod if tmp2==0: break tmp2-=1 else: tmp2+=1 print((pow(K,N,mod)-ans)%mod)