#include using namespace std; const int MaxN = (int)1e5 + 10; const int MOD = (int)1e9 + 7; const int INF = 1e9 + 1; int bits[1 << 16]; int countBits(long long x) { int res = 0; while (x > 0) { res += bits[x & 65535]; x >>= 16; } return res; } int zerosEnd(long long x) { int res = 0; while (x % 2 == 0) { res += 1; x /= 2; } return res; } void solve() { long long a, b; scanf("%lld%lld", &a, &b); assert (0 <= a && a <= 1e18); assert (0 <= b && b <= 1e18); if (a == b) { printf("0\n"); return; } if (b == 1 && a == 0) { printf("1\n"); return; } if (b <= 1) { printf("-1\n"); return; } int last = countBits(b) + zerosEnd(b) - 1; if (countBits(a) <= last) { printf("%d\n", last - countBits(a) + 1); return; } printf("2\n"); } int main() { // freopen("input.txt", "r", stdin); // ios::sync_with_stdio(false); cin.tie(NULL); for (int i = 1; i < 1 << 16; ++i) { bits[i] = bits[i / 2] + (i & 1); } int t; scanf("%d", &t); assert (1 <= t && t <= 1e5); while (t --> 0) { solve(); } return 0; }