#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long int BtoPmodM(long long int b, long long int p, long long int m) {
  b %= m;
  if (p == 0)
    return 1;
  else if (p % 2 == 0)
    return (BtoPmodM(b, p / 2, m) * BtoPmodM(b, p / 2, m)) % m;
  else if (p % 2 == 1)
    return (BtoPmodM(b, (p - 1) / 2, m) * BtoPmodM(b, (p - 1) / 2, m) * b) % m;
  else
    return 0;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
bool coprime(long long int a, long long int b) {
  if (gcd(a, b) == 1)
    return true;
  else
    return false;
}
long long int factModP(long long int n, long long int p) {
  long long int fac[n - 1];
  fac[0] = 1;
  for (long long int i = 1; i <= n; i++) {
    fac[i] = fac[i - 1] * i % p;
  }
  return fac[n];
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y /= 2;
    x = (x * x) % p;
  }
  return res;
}
long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2, p);
}
long long int nCrModP(long long int n, long long int r, long long int p) {
  if (r == 0)
    return 1;
  else if (r > n)
    return 0;
  long long int fac[n + 1];
  fac[0] = 1;
  for (long long int i = 1; i <= n; i++) {
    fac[i] = fac[i - 1] * i % p;
  }
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
long long int nCr(long long int n, long long int r) {
  long long int ans = 1;
  if (r >= n - r) {
    for (long long int i = r + 1; i <= n; i++) ans *= i;
    for (long long int i = 1; i <= n - r; i++) ans /= i;
  } else {
    for (long long int i = n - r + 1; i <= n; i++) ans *= i;
    for (long long int i = 1; i <= r; i++) ans /= i;
  }
  return ans;
}
long long int string_to_int(string str) {
  int strl = str.length();
  long long int ans = 0;
  if (str[0] == '-') {
    for (int i = 1; i < strl; i++) ans += pow(10, strl - i - 1) * (str[i] - 48);
    ans = 0 - ans;
    return ans;
  }
  for (int i = 0; i < strl; i++) ans += pow(10, strl - i - 1) * (str[i] - 48);
  return ans;
}
struct edge_stru {
  int u, v, w;
};
edge_stru make_edge_stru(int u, int v, int w) {
  edge_stru a = {u, v, w};
  return a;
}
class cmp {
 public:
  bool operator()(edge_stru a, edge_stru b) { return a.w > b.w; }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int q;
  cin >> q;
  while (q--) {
    long long int a, b;
    cin >> a >> b;
    if (b > a) swap(a, b);
    long long int g = gcd(a, b);
    a /= g;
    b /= g;
    long long int cnt = 0;
    if (a == b) {
      cout << "0\n";
    } else if (ceil(log2(a * 1.0 / b)) != floor(log2(a * 1.0 / b))) {
      cout << "-1\n";
    } else {
      while (a >= 8) {
        a /= 8;
        cnt++;
      }
      if (a != b) cnt++;
      cout << cnt << endl;
    }
  }
}
