n,k = map(int,input().split()) lr = [] for _ in range(n): l,r = map(int,input().split()) lr.append((l,1)); lr.append((r,0)) mod = 998244353; c = 0; x = 1 for _,f in sorted(lr): if f: x = x*max(k-c,0)%mod; c += 1 else: c -= 1 print((pow(k,n,mod)-x)%mod)