#ifdef DEBUG #include"stdlibrary.h" #else #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; #endif // #include // #include // #include // using namespace __gnu_pbds; // #include // namespace multiprecisioninteger = boost::multiprecision; // using cint=multiprecisioninteger::cpp_int; using ll=long long; using datas=std::pair; using ddatas=std::pair; using tdata=std::pair; using vec=std::vector; using mat=std::vector; using pvec=std::vector; using pmat=std::vector; // using llset=tree,rb_tree_tag,tree_order_statistics_node_update>; #define For(i,a,b) for(i=a;i<(ll)b;++i) #define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i) #define rep(i,N) For(i,0,N) #define rep1(i,N) For(i,1,N) #define brep(i,N) bFor(i,N,0) #define brep1(i,N) bFor(i,N,1) #define all(v) std::begin(v),std::end(v) #define allr(v) std::rbegin(v),std::rend(v) #define vsort(v) std::sort(all(v)) #define vrsort(v) std::sort(allr(v)) #define uniq(v) vsort(v),(v).erase(std::unique(all(v)),std::end(v)) #define endl "\n" #define popcount __builtin_popcountll #define print(x) std::cout< std::ostream& operator<<(std::ostream& os,const T& v){return os< std::ostream& operator<<(std::ostream& os,const std::vector& v); template std::ostream& operator<<(std::ostream& os,const std::set& v); template std::ostream& operator<<(std::ostream& os,const std::multiset& v); template std::ostream& operator<<(std::ostream& os,const std::map& v); template std::ostream& operator<<(std::ostream& os,const std::pair& p){return os<<"("< std::ostream& operator<<(std::ostream& os,const std::vector& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< std::ostream& operator<<(std::ostream& os,const std::set& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< std::ostream& operator<<(std::ostream& os,const std::multiset& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< std::ostream& operator<<(std::ostream& os,const std::map& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< inline bool chmax(T& a,const T b){bool x=a inline bool chmin(T& a,const T b){bool x=a>b;if(x)a=b;return x;} #ifdef DEBUG void debugg(){std::cout<void debugg(const T& x,const Args&... args){std::cout<<" "<sync_with_stdio(0); cout<size;--i)modncrlistm[i-1]=modncrlistm[i]*i%mod; } return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod; } ll modpow(ll a,ll n,const ll m=mod){ if(n<0)return 0; ll res=1; while(n>0){ if(n&1)res=res*a%m; a=a*a%m; n>>=1; } return res; } constexpr ll gcd(const ll a,const ll b) noexcept{return (!b)?abs(a):(a%b==0)?abs(b):gcd(b,a%b);} constexpr ll lcm(const ll a,const ll b) noexcept{return a/gcd(a,b)*b;} struct unionfind{ private: int maxN; vector par,treesize; public:unionfind(int N) :maxN(N),par(N),treesize(N,1){ for(int i=0;itreesize[y])swap(x,y); par[x]=y; treesize[y]+=treesize[x]; return true; } bool merge(pair v){ return merge(v.first,v.second); } bool same(int x,int y){ return root(x)==root(y); } bool same(pair v){ return same(v.first,v.second); } int size(int x){ return treesize[root(x)]; } void clear(){ treesize.assign(maxN,1); for(int i=0;i> groups(){ vector> res(maxN); for(int i=0;i> res2; for(vector x:res){ if(x.size())res2.emplace_back(x); } return res2; } }; #include using mint=atcoder::modint998244353; // void operator>>(istream& is,mint& v){long long x;is>>x;v=x;} ll N,M,K,H,W,A,B,C,D; string s,t; ll ans; int main(){ startupcpp(); // int codeforces;cin>>codeforces;while(codeforces--){ ll i,j; cin>>N>>K; if(N==1){ const int ch[]={1,1,3,3,3,1,1}; print(ch[K]); return 0; } vector p1(N*2+4),p2(N*2+4),p3(N*2+4); iota(all(p1),0); reverse(all(p1)); iota(all(p2),0); rotate(p2.begin(),p2.begin()+N+2,p2.end()); iota(all(p3),0); reverse(p3.begin(),p3.begin()+N+2); reverse(p3.end()-N-2,p3.end()); debug(p1); debug(p2); debug(p3); auto apply=[](const vector& p,const vector& q){ vector nxt(p.size()); int i; rep(i,p.size())nxt[i]=q[p[i]]; return nxt; }; mint ans; std::set> st; for(auto i:{0,1})for(auto j:{0,1})for(auto k:{0,1}){ vector p(N*2+4); iota(all(p),0); if(i)p=apply(p,p1); if(j)p=apply(p,p2); if(k)p=apply(p,p3); if(!st.emplace(p).second)continue; debug(p); unionfind dsu(N*2+4); rep(i,N*2+4) dsu.merge(i,p[i]); queue> que; for(auto v:dsu.groups()){ auto&ch=que.emplace(v.size()+1); ch.front()=1; ch.back()=1; } while(que.size()>1){ auto a=que.front();que.pop(); auto b=que.front();que.pop(); auto c=atcoder::convolution(a,b); que.emplace(move(c)); } ans+=que.front()[K]; } print(ans/st.size()); // } }