#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int H,W,N; map>,ll> from[55],to[55]; const ll mo=998244353; void solve() { int i,j,k,l,r,x,y; string s; cin>>H>>W>>N; int mask; FOR(mask,1<<(W+1)) { if(mask&&__builtin_popcount(mask)%2==0) { vector> V; FOR(i,7) if(mask&(1<> V=v; vector R; sort(ALL(V)); int pre=V[0].first; int ok=1; for(j=1;jV[0].second) ok=0; if(ok) (ret+=p*(H+1-y))%=mo; } FOR(mask,1<<(W+1)) if(mask&&__builtin_popcount(mask)%2==0) { FORR2(v,p,from[i]) { int over[7]; int t[14]; MINUS(over); MINUS(t); FORR(w,v) over[w.first]=w.second,over[w.second]=w.first; int pre=-1; int ng=0; int add=0; FOR(x,W+1) { if(over[x]>=0&&(mask&(1<=0) { if(pre==-1) pre=x,add++; else t[pre]=x,t[x]=pre,pre=-1; } else if(mask&(1<N) continue; /* cout<<"!"<> NV; FOR(x,W+1) if(vis[x+W+1]==0&&t[x+W+1]>=0) { vis[x+W+1]=1; NV.push_back({x,0}); j=t[x+W+1]; while(j=0&&vis[x]==0) ng=1; } if(ng) continue; /* cout< "; FORR(v,NV) cout<