MOD = 998244353 N, K = map(int, input().split()) event = [] for i in range(N): l, r = map(int, input().split()) event.append((l, 1)) event.append((r, 0)) event.sort() cnt = 0 ans = 1 for i in range(2 * N): x, t = event[i] if t == 1: if cnt == K: ans = 0 else: ans *= K - cnt cnt += 1 else: cnt -= 1 print((pow(K, N, MOD) - ans) % MOD)