n,k = map(int,input().split()) mod = 998244353 lr = [] for i in range(n): l,r = map(int,input().split()) lr.append([l, 1]) lr.append([r, -1]) lr.sort() ans = 1 now = 0 for a,b in lr: if b == -1: now -= 1 else: ans *= k-now now += 1 ans %= mod ans = pow(k, n, mod) - ans ans %= mod print(ans)