#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; 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> dps={{1}}; REP(i, m) { ll l, r; cin >> l >> r; if((r-l)%2){ ll d=(r-l+1)/2; vector add(d+1); add[0]=1; add[d]=-f[d*2]*rf[d]*rf[d]/(d+1); dps.push_back(add); } } while(dps.size()>1){ vector> ndps; REP(i,dps.size() / 2){ ndps.push_back(convolution(dps[i*2],dps[i*2+1])); } if(dps.size()%2){ ndps.push_back(dps.back()); } swap(dps,ndps); } mint ans = 0; REP(i, dps[0].size()) { ans += dps[0][i] * f[n - i * 2] * rf[n / 2 - i] * rf[n / 2 - i] / (n / 2 - i + 1); } cout << ans.val(); return 0; }