ll@T;rep(T){ll@N,p=BIT_popcount(N),y=N,a=-1;rep(d,31)if(y>>d&1){y+=1<BIT_popcount(y))a=y-N,break;}wt(a);}