#ifdef MY_LOCAL
#include "D://competitive_programming/debug/debug.h"
#define debug(x) cerr << "[" << #x<< "]:"<<x<<"\n"
#else
#define debug(x) 
#endif
#define REP(i, n) for(int i = 0; i < n; i ++)
#define REPL(i,m, n) for(int i = m; i < n; i ++)
#define SORT(arr) sort(arr.begin(), arr.end())
#define LSOne(S) ((S)&-(S))
#define M_PI 3.1415926535897932384
#define INF 1e18
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef double ld;
typedef tree<int,null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;
const int MOD = 998244353;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;cin>>n>>k;
	vector<ii> events;
	REP(i, n) {
		int l,r;cin>>l>>r;
		events.push_back({l, i+1});
		events.push_back({r, -i-1});
	}
	SORT(events);
	int bad = 1;
	int curav = k;
	for (auto [t, ty]: events) {
		if (ty < 0) curav++;
		if (ty > 0) {
			//debug(curav);
			int nn = max(0LL, curav);
			bad *= nn;
			bad %= MOD;
			curav--;
		}
	}
	//debug(bad);
	int tot = 1;
	REP(i, n) {
		tot *= k;
		tot %= MOD;
	}
	cout<<(tot-bad+MOD)%MOD;
}