import sys readline = sys.stdin.readline N, K = map(int, readline().split()) mod = 998244353 inf = 10 ** 18 D = [(inf, inf)] cnt = [0] * 202020 for i in range(N): L, R = map(int, readline().split()) D.append((L, R)) D.sort(reverse=True) val = 1 size = 0 for i in range(202020): size -= cnt[i] while D[-1][0] == i: _, r = D.pop() cnt[r] += 1 size += 1 val *= K + 1 - size val %= mod print( (pow(K, N, mod) - val)%mod )