MOD = 998244353 from heapq import * N, K = map(int, input().split()) LR = [list(map(int, input().split())) for _ in range(N)] LR.sort() q = [] cnt = 0 All = pow(K, N, MOD) tmp = 1 for l, r in LR: if q: while q and q[0] <= l: cnt -= 1 heappop(q) tmp *= (K - cnt) tmp %= MOD cnt += 1 heappush(q, r) print((All - tmp) % MOD)