#include <bits/stdc++.h>
int get(long long x) {
  while (x % 2 == 0) x /= 2;
  return x;
}
using namespace std;
int minOp(long long x, long long y) {
  int r1 = get(x);
  int r2 = get(y);
  int ans = 0;
  if (r1 != r2) {
    return -1;
  } else {
    x /= y;
    while (x >= 8) {
      ans++;
      x /= 8;
    }
    if (x > 1) {
      ans++;
    }
  }
  return ans;
}
int main(int argc, char** argv) {
  int t;
  cin >> t;
  while (t--) {
    long long x, y;
    cin >> x >> y;
    if (x > y)
      cout << minOp(x, y) << endl;
    else
      cout << minOp(y, x) << endl;
  }
  return 0;
}
