//g++ 1.cpp -std=c++17 -O2 -I . #include using namespace std; #include using namespace atcoder; using ll = long long; using ld = long double; using vi = vector; using vvi = vector; using vll = vector; using vvll = vector; using vld = vector; using vvld = vector; using vst = vector; using vvst = vector; #define fi first #define se second #define pb push_back #define eb emplace_back #define pq_big(T) priority_queue,less> #define pq_small(T) priority_queue,greater> #define all(a) a.begin(),a.end() #define rep(i,start,end) for(ll i=start;i<(ll)(end);i++) #define per(i,start,end) for(ll i=start;i>=(ll)(end);i--) #define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end()) constexpr ll mod = 998244353; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n;ll k; cin>>n>>k; int now=0; vector> t; // time,id, open or leave rep(i,0,n){ int l,r;cin>>l>>r; t.emplace_back(l,i,1); t.emplace_back(r,i,0); } sort(all(t)); ll ans=1; for(auto [time,id,op]:t){ if(op==0){ now--; } else{ if(k<=now)ans=0; ans*=k-now; ans%=mod; now++; } } ans=pow_mod(k,n,mod)-ans; ans%=mod; if(ans<0)ans+=mod; cout<