#include #define ll long long #define rep(i,x,n) for(ll i=x;i=n;i--) using namespace std; ll mod=1000000007; void solve(){ ll d; cin>>d; ll init=d; ll mx=floor(log2(d)); // ll dp[mx][mx]; ll sum=0,ans=(1LL<<(mx-1LL)); d-=((1LL< v1LL; ll res=LLONG_MAX; rrep(i,mx-2,0){ if(d-(1LL<<(i+1LL))+1LL >0) {d-= ((1LL<<(i+1LL))-1LL); ans+= (1LL<0) ans=min(init,res); cout<