#include #include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; using ll = long long; #define REP(i, n) for(ll i=0; i<(n);i++) #define PER(i, n) for(ll i=n-1; i>=0;i--) int main() { ll n, m; cin >> n >> m; vector cnt(n + 1); REP(i, m) { ll l, r; cin >> l >> r; cnt[r - l + 1]++; } if (n % 2) { cout << 0; return 0; } vector f(n + 1, 1), rf(n + 1, 1); REP(i, n) { f[i + 1] = f[i] * (i + 1); rf[i + 1] = mint(1) / f[i + 1]; } vector p = { 1 }; REP(d, n + 1) { if (d % 2 || cnt[d] == 0) continue; mint vv = -f[d] * rf[d / 2] * rf[d / 2] / (d / 2 + 1); if (cnt[d] < 35) { p.resize(p.size() + d / 2 * cnt[d]); REP(i, cnt[d]) { PER(i, p.size() - d / 2) { p[i + d / 2] += vv * p[i]; } } } else { vector mul(d / 2 * cnt[d] + 1); REP(i, cnt[d] + 1) { mul[d / 2 * i] = vv.pow(i) * f[cnt[d]] * rf[i] * rf[cnt[d] - i]; } p = convolution(p, mul); } } mint ans = 0; REP(i, p.size()) { ans += p[i] * f[n - i * 2] * rf[n / 2 - i] * rf[n / 2 - i] / (n / 2 - i + 1); } cout << ans.val(); return 0; }