#include using namespace std; using ll=__int128; struct T{ ll v; long long cnt; long long bad; }; T e=T{0,0,0}; T operator+(T lhs,T rhs){ return T{lhs.v+rhs.v,lhs.cnt+rhs.cnt,lhs.bad+rhs.bad}; } T operator-(T lhs,T rhs){ return T{lhs.v-rhs.v,lhs.cnt-rhs.cnt,lhs.bad-rhs.bad}; } T operator*(T lhs,T rhs){ return T{lhs.v*rhs.v,lhs.cnt*rhs.cnt,lhs.bad*rhs.cnt+lhs.cnt*rhs.bad-lhs.bad*rhs.bad}; } ll mygcd(ll a,ll b){ return b==0 ? a : mygcd(b,a%b); } const int LOG_N=18; const int MAX_N=1< B(MAX_N,e); void solve(int step,vector A,int mask){ if(A.size()==1){ B[mask]=B[mask]+A[0]*A[0]; return; } vector odd(A.size()/2,e); for(int i=1;i even(A.size()/2,e); for(int i=0;i>n; ll deb=0; vector A(MAX_N,e); for(int i=0;i>tmp; if(tmp==-1) deb++; if(tmp==-1) A[i]={0,1,1}; else A[i]={tmp,1,0}; } solve(0,A,0); vector B2(MAX_N); for(int i=0;i