int n, m; int a[N]; int query(int root,int x,int y){ //cerr<<root<<endl; if(root>max(x,y))return -1; if(root==x||root==y)return root; int l=query(2*root,x,y); int r=query(2*root+1,x,y); if(l==-1&&r==-1)return -1; if(l!=-1&&r!=-1)return root; if(l!=-1&&r==-1)return l; if(l==-1&&r!=-1)return r; } void solve(){ int x,y; while(cin>>x>>y,x!=0){ cout<<query(1,x,y)<<endl; } } int main() { cin.tie(0); ios::sync_with_stdio(false);
int t; //cin>>t; t=1; while (t--) { solve(); } return 0; }