#include <bits/stdc++.h>
using namespace std;
int Solve(unsigned long long x) {
  int rez = 0;
  int steps = 0;
  while (x) {
    rez += x % 2;
    x /= 2;
    steps++;
  }
  if (rez > 1) {
    return -1;
  }
  steps--;
  int st1 = steps / 3;
  steps %= 3;
  int st2 = steps / 2;
  steps %= 2;
  return steps + st1 + st2;
}
void Main() {
  unsigned long long a, b;
  cin >> a >> b;
  unsigned long long div = -1;
  if (a % b == 0) div = a / b;
  if (b % a == 0) div = b / a;
  if (div == -1) {
    cout << -1 << endl;
    return;
  }
  if (div == 1) {
    cout << 0 << endl;
    return;
  }
  cout << Solve(div) << endl;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) Main();
}
