#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 struct combi{ deque kaijou; deque kaijou_; combi(int n){ kaijou.push_back(1); for(int i=1;i<=n;i++){ kaijou.push_back(kaijou[i-1]*i); } mint b=kaijou[n].inv(); kaijou_.push_front(b); for(int i=1;i<=n;i++){ int k=n+1-i; kaijou_.push_front(kaijou_[0]*k); } } mint combination(int n,int r){ if(r>n)return 0; mint a = kaijou[n]*kaijou_[r]; a *= kaijou_[n-r]; return a; } mint junretsu(int a,int b){ mint x = kaijou_[a]*kaijou_[b]; x *= kaijou[a+b]; return x; } mint catalan(int n){ return combination(2*n,n)/(n+1); } }; combi C(1000000); int main(){ int n,m; cin>>n>>m; queue> Q; rep(i,m){ int l,r; cin>>l>>r; l--; int len = r-l; if(len%2)continue; len /= 2; vector t(len+1); t[0] = 1; t[len] = -C.catalan(len); Q.push(t); } Q.push({1}); while(Q.size()>=2){ vector a = Q.front(); Q.pop(); auto b = Q.front(); Q.pop(); Q.push(convolution(a,b)); } mint ans = 0; n /= 2; rep(i,Q.front().size()){ mint t = Q.front()[i]; t *= C.catalan(n-i); ans += t; } cout<