#include #include #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++) #define rep2ll(i,m,n) for(ll (i)=(m);(i)<(n);(i)++) #define ALL(obj) (obj).begin(), (obj).end() #define rALL(obj) (obj).rbegin(), (obj).rend() using namespace std; using ll = long long; using P = pair; using mint = atcoder::modint998244353; using VL = vector; using VVL = vector; using VVVL = vector; using VM = vector; using VVM = vector; using VVVM = vector; using VD = vector; using VVD = vector; using VVVD = vector; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b struct Combination { vector< T > _fact, _rfact, _inv; Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) { _fact[0] = _rfact[sz] = _inv[0] = 1; for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i; _rfact[sz] /= _fact[sz]; for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1); for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1]; } inline T fact(int k) const { return _fact[k]; } inline T rfact(int k) const { return _rfact[k]; } inline T inv(int k) const { return _inv[k]; } T P(int n, int r) const { if(r < 0 || n < r) return 0; return fact(n) * rfact(n - r); } T C(int p, int q) const { if(q < 0 || p < q) return 0; return fact(p) * rfact(q) * rfact(p - q); } T H(int n, int r) const { if(n < 0 || r < 0) return (0); return r == 0 ? 1 : C(n + r - 1, r); } }; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n, m; cin>>n>>m; VL cnt(n/2+1, 0); bool zero = n%2; rep(i,m){ ll l, r; cin>>l>>r; l--; zero |= (r-l)%2; cnt[(r-l)/2]++; } if(zero){ cout<<0; return 0; } n /= 2; vector

arr; rep(i,n+1) if(cnt[i]) arr.push_back({i, cnt[i]}); Combination c(2*n+1); VM cata(n+1, 0); rep(i,n+1) cata[i] = c.fact(2*i) * c.rfact(i+1) * c.rfact(i); VM dp(1, 1); for(auto [x, y]: arr){ VM dp_(x*y+1, 0); rep(j, y+1) dp_[x*j] = cata[x].pow(j) * c.C(y, j) * (1-j%2*2); dp = atcoder::convolution(dp, dp_); } mint ans = 0; rep(i,dp.size()) ans += dp[i] * cata[n-i]; cout<