from heapq import heappop,heappush

N,K=map(int,input().split())
LR=[tuple(map(int,input().split())) for i in range(N)]

LR.sort()
ANS=1
mod=998244353

Q=[]

for l,r in LR:
    while Q and Q[0]<=l:
        heappop(Q)

    ANS=ANS*(K-len(Q))%mod
    heappush(Q,r)

print((pow(K,N,mod)-ANS)%mod)