#include using namespace std; #define rep(i,n) for (ll i = 0; i < n; ++ i) using ll = long long ; using vi = vector; using vb = vector; using vvi = vector; const ll mod = 998244353; //---------------------------------------------------------------- const ll si_f = 5e5; ll f[si_f+1], invf[si_f+1], inv[si_f+1]; ll po(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; } //---------------------------------------------------------------- void solver(ll x,ll &res,ll id){ if(x%2==0){ ll y = x/2; ll c = C(x,y) * po(y+1,mod-2) % mod; res = res * c % mod; } else if(id == 0){ ll y = x/2; ll c = 2 * C(x,y) * po(y+2,mod-2) % mod; res = res * c % mod; } else res = 0; return; } //---------------------------------------------------------------- int main(){ init(); int N,Q; cin >> N >> Q; vi imos(N+1,0),L(Q),R(Q); rep(i,Q){ cin >> L[i] >> R[i]; --L[i]; imos[L[i]] += (1< kukan; rep(i,N) ++kukan[imos[i]]; ll res = f[N/2]*f[(N+1)/2] % mod; for(auto siz:kukan){ solver(siz.second,res,siz.first); } cout << res << endl; }