#ifdef MY_LOCAL #include "D://competitive_programming/debug/debug.h" #define debug(x) cerr << "[" << #x<< "]:"< #include #include using namespace __gnu_pbds; using namespace std; typedef long long ll; #define int ll typedef vector vi; typedef vector vvi; typedef pair ii; typedef vector vii; typedef vector vvii; typedef double ld; typedef tree, 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 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; }