#include #include #include using namespace std; const int maxn=35; typedef long long LL; const LL oo=0x3f3f3f3f3f3f3f3fll; int T,L,a,b,c; LL f[maxn][maxn][maxn][maxn][2]; inline void CM(LL &a,const LL &b) { a=min(a,b); } int read() { int x; scanf("%d",&x); int stk[80],cnt=0; while(x) stk[cnt++]=x&1,x>>=1; L=max(L,cnt); x=0; for(int i=0;i0) { L=0; a=read(); b=read(); c=read(); printf("%lld\n",f[L][a][b][c][0]==oo?-1:f[L][a][b][c][0]); } return 0; }