#include #include using namespace std; using lint=long long; using mint=atcoder::static_modint<998244353>; #define rep(i,n) for(int i=0;i v; rep(i,8)cin>>v[i]; rep(i,8)v[i]-=4; if(v[0]+v[1]+v[2]+v[3]!=v[4]+v[5]+v[6]+v[7]){ cout<<0<> dp(31,vector(1<<14)); dp[0][0]=1; arraya; a.fill(0); rep(i,1<<9){ rep(j,3)rep(k,3){ if(i>>(j*3+k)&1){ a[i]+=1<<(j*2); a[i]+=1<<((k+3)*2); } } } arrayv2; v2.fill(0); rep(d,30){ rep(j,7){ v2[d]+=(v[j]>>d&1)<<(j*2); } } rep(d,30){ //flag : 解説におけるh',w' を2bitずつに割り当てたもの rep(flag,1<<14){ rep(i,1<<9){ // 前半3制約の内遇奇が合わない物 const lint tmp=((flag^a[i]^v2[d])&21LL); // 7つ目の制約の変化量 const lint cnt=__builtin_popcountll(tmp); // 遷移の値を加算したもの assert(cnt<4); const lint tmp2=(flag+a[i]+(cnt<<12))+(((flag^(a[i]+(cnt<<12)))^v2[d])&5461LL)-v2[d]; assert(v2[d]==(v2[d]&5461LL)); // 竹DPの更新後の値 assert(tmp2>=0); assert(tmp2%2==0); const lint tmp3=tmp2/2; assert(tmp3<(1LL<<14)); dp[d+1][tmp3]+=dp[d][flag]; } } } cout<