#include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template ostream& operator<<(ostream &os, const pair &p) { return os << '(' << p.first << ", " << p.second << ')'; } template::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector vi; typedef vector vvi; typedef pair pi; const int mxN = 1<<20, oo = 1e9; const long long MD = 998244353; template struct mdint { int d; mdint () {d=0;} mdint (long long _d) : d(_d%MOD){ if(d<0) d+=MOD; }; friend mdint& operator+=(mdint& a, const mdint& o) { a.d+=o.d; if(a.d>=MOD) a.d-=MOD; return a; } friend mdint& operator-=(mdint& a, const mdint& o) { a.d-=o.d; if(a.d<0) a.d+=MOD; return a; } friend mdint& operator*=(mdint& a, const mdint& o) { return a = mdint((ll)a.d*o.d); } mdint operator*(const mdint& o) const { mdint res = *this; res*=o; return res; } mdint operator+(const mdint& o) const { mdint res = *this; res+=o; return res; } mdint operator-(const mdint& o) const { mdint res = *this; res-=o; return res; } mdint operator^(long long b) const { mdint tmp = 1; mdint power = *this; while(b) { if(b&1) { tmp = tmp*power; } power = power*power; b/=2; } return tmp; } friend mdint operator/=(mdint& a, const mdint& o) { a *= (o^(MOD-2)); return a; } mdint operator/(const mdint& o) { mdint res = *this; res/=o; return res; } bool operator==(const mdint& o) { return d==o.d;} bool operator!=(const mdint& o) { return d!=o.d;} friend istream& operator>>(istream& c, mdint& a) {return c >> a.d;} friend ostream& operator<<(ostream& c, const mdint& a) {return c << a.d;} }; using mint = mdint; const int mxF = 2e6+2; mint fact[mxF], ifact[mxF]; mint ncr(int a, int b) { if(b>a or a<0 or b<0) return 0; return fact[a]*ifact[b]*ifact[a-b]; } void precomp() { fact[0]=1; for(int i=1;i=0;--i) { ifact[i]=ifact[i+1]*(i+1); } } typedef mint cd; void revperm(cd* in, int n) { for(int i=0,j=0;i> 1; (j ^= k) < k; k >>= 1); } } cd w[mxN+1]; // stores w^j for each j in [0,n-1] void precomp2() { w[0] = 1; int pw = (MD-1)/mxN; w[1] = mint(3)^pw; for(int i= 2;i<=mxN;++i) { w[i] = w[i-1]*w[1]; } } void fft(cd* in, int n, bool reverse=false) { int lg = __lg(n); assert(1<>s); for(int j=0;j polymul(vector a, vector b) { int n = a.size(), m = b.size(), ptwo = 1; while(ptwo<(n+m)) ptwo*=2; a.resize(ptwo), b.resize(ptwo); fft(a.data(),ptwo); fft(b.data(),ptwo); for(int i=0;i> n >> m; vi ws; for(int i=0;i> l >> r; --l,--r; if((r-l+1)%2==0) { ws.push_back(r-l+1); } } m = ws.size(); auto mul = [&](auto&& self, int l, int r) -> vector { if(l==r) return {1}; // cerr << l << ' ' << r << '\n'; if(l+1==r) { vector v( (ws[l]/2+1)); v[ws[l]/2]=mint(0)-catalan(ws[l]); v[0]+=1; return v; } auto mid = (l+r)/2; return polymul(self(self,l,mid), self(self,mid,r)); }; vector res = mul(mul,0,m); // normally: n brackets mint ans=0; for(int i=0;i