a lot of us are on limited / monitored web access @ work.
unless you want to post the problem I can't see it. But there is an EPIC thread on a binary shuffle problem on these forums... look for it, its recent and ongoing, and may or may not apply to your problem.
Chef has two integers A and B. He can perform the following operation on A an arbitrary number of times (including zero):
write A as a binary number with an arbitrary number of leading zeroes (possibly without any)
shuffle the binary digits of A in an arbitrary way, obtaining a number s
replace A by s+1
Chef is wondering about the minimum number of operations he has to perform on A in order to obtain B. Compute this number or determine that it is impossible.
Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first and only line of each test case contains two space-separated integers A and B.
Output
For each test case, print a single line containing one integer — the minimum number of operations or −1 if it is impossible to obtain B from A.