#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
const long long MOD = 998244353;
const long long INF = 0x3f3f3f3f;
long long read() {
  long long x = 0, f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - 48;
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return x * f;
}
long long N, M;
void init() {}
void check(long long x) {
  string res = "";
  while (x) {
    res += x % 2 + '0';
    x >>= 1;
  }
  reverse(res.begin(), res.end());
  cout << res;
  printf("!\n");
}
void solve() {
  int ans;
  long long a, b;
  N = read();
  M = read();
  for (ans = 0, a = N, b = M; a; ans++) {
    if (a == b) {
      break;
    }
    if (a % 2) {
      ans = -1;
      break;
    }
    a >>= 1;
  }
  if (~ans) {
    ans = ans / 3 + (ans % 3 ? 1 : 0);
    printf("%d\n", ans);
    return;
  }
  for (ans = 0, a = N, b = M; a; ans++) {
    if (a == b) {
      break;
    }
    if (a > INF * INF) {
      ans = -1;
      break;
    }
    a <<= 1;
  }
  printf("%d\n", ~ans ? ans / 3 + (ans % 3 ? 1 : 0) : ans);
}
int main() {
  int T;
  T = 1;
  scanf("%d", &T);
  while (T--) {
    solve();
  }
  return 0;
}
