#include using namespace std; #define rep(i,n) for (ll i = 0; i < n; ++ i) using ll = long long ; using vi = vector; const ll mod = 998244353; //---------------------------------------------------------------- const ll si_f = 5e5; ll f[si_f+1], invf[si_f+1], inv[si_f+1]; ll modpow(ll n,ll m){ ll res = 1; while (m) { if (m&1) res = res * n % mod; n = n * n % mod; m /= 2; } return res; } void init() { f[0] = f[1] = 1; invf[0] = invf[1] = 1; inv[1] = 1; for(ll i = 2; i < si_f; ++i){ f[i] = f[i-1] * i % mod; inv[i] = mod - inv[mod%i] * (mod/i) % mod; invf[i] = invf[i-1] * inv[i] % mod; } return; } ll C(int n, int k) { ll a = f[n]; // = n! ll b = invf[n-k]; // = (n-k)! ll c = invf[k]; // = k! ll bc = (b * c) % mod; return (a * bc) % mod; } //---------------------------------------------------------------- int main(){ init(); int N,Q; cin >> N >> Q; assert(1 <= N && N <= 2e5); assert(0 <= Q && Q <= 60); vi imos(N+1,0); rep(i,Q){ ll L,R; cin >> L >> R; assert(1 <= L && L <= R && R <= N); imos[L-1] += (1LL< kukan; rep(i,N) ++kukan[imos[i]]; ll res = f[N/2]*f[N - N/2] % mod; if(N%2 == 1) ++kukan[0]; for(auto t:kukan){ int l = t.second; if(l%2 == 0){ int x = l/2; ll c = C(l,x) * modpow(x+1,mod-2) % mod; res = res * c % mod; } else res = 0; } cout << res << endl; }