#include #include #include using namespace std; using ll = long long; #include #include using ull = unsigned long long; ull hah(vector&c){ const ull B = 998244353; ull sum = 0; ull now = 1; for(int i = 1;i<=9;i++){ for(int j = 0;j>n; vector c(10,0); for(int i = 1;i<=9;i++) cin>>c[i]; if(n==1){ int ans = 0; for(int i = 1;i<=9;i++) ans += c[i]; int cnt = 0; while(true){ if(ans&1) break; ans >>= 1; cnt++; } cout<=30;kk--){ ll k = 1ll << kk; while(true){ string s = to_string(k); if(s.size()>n) break; if(s.size() nc(10,0); for(int i = 0;i=0;kk--){ ll k = 1ll << kk; vector a,b; ll now = 1; for(int i = 0;i> m1,m2; vector use(10,0); ll ans = 0; auto calc = [&](vector&now) { vector all; for(int i = 1;i<=9;i++) for(int j = 0;j&now){ vector all; for(int i = 1;i<=9;i++) for(int j = 0;j nxt(10,0); for(int i = 1;i<=9;i++) nxt[i] = c[i] - now[i]; ans += m2[hah(nxt)][want]; }while(next_permutation(all.begin(),all.end())); }; bool fn = false; auto dfs = [&](auto dfs,int ni,int res) -> void { if(res==0){ if(!fn) calc(use); else calc1(use); return; } for(int i = ni;i<=9;i++){ if(c[i]==0) continue; c[i]--; use[i]++; dfs(dfs,i,res-1); use[i]--; c[i]++; } }; dfs(dfs,1,a.size()); swap(a,b); fn = true; swap(m1,m2); dfs(dfs,1,a.size()); // for(auto itr:m1){ // auto use = itr.first; // vector want(10,0); // for(int i = 1;i<=9;i++) want[i] = c[i] - use[i]; // auto now = m2[hah(want)]; // for(auto nn:itr.second){ // ll w = k - nn.first; // w %= k; // if(w<0) w += k; // ans += nn.second * now[w]; // } // } if(ans==0) continue; cout<