#include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } //defmodfact const int COMinitMAX = 998244; mint fact[COMinitMAX+1], factinv[COMinitMAX+1]; void modfact(){ fact[0] = 1; for (int i=1; i<=COMinitMAX; i++){ fact[i] = fact[i-1] * i; } factinv[COMinitMAX] = fact[COMinitMAX].inv(); for (int i=COMinitMAX-1; i>=0; i--){ factinv[i] = factinv[i+1] * (i+1); } } mint cmb(int a, int b){ if (a> n >> m; vector b(m); rep(i,0,m){ int l, r; cin >> l >> r; b[i] = r - l + 1; } vector catalan(n+1); rep(i,0,n+1){ catalan[i] = fact[2 * i] * factinv[i + 1] * factinv[i]; } if (n % 2 == 1){ cout << 0 << '\n'; return 0; } deque> deq; rep(i,0,m){ if (b[i] % 2 == 1){ continue; } vector tar(b[i] / 2 + 1, 0); tar[0] = 1; tar[b[i] / 2] = - catalan[b[i] / 2]; deq.push_back(tar); } while(deq.size() >= 2){ vector x = deq.front(); deq.pop_front(); vector y = deq.front(); deq.pop_front(); deq.push_back(convolution(x, y)); } vector x = deq.front(); x.resize(n + 1); mint ans = 0; rep(i,0,n+1){ ans += x[i] * catalan[n / 2 - i]; } cout << ans.val() << '\n'; }