#include <bits/stdc++.h>
using namespace std;
void input(vector<long long>& v, long n) {
  for (long long i = 0; i < n; i++) {
    long long in;
    cin >> in;
    v.push_back(in);
  }
}
void output(vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
}
long long max_of_three(long long a, long long b, long long c) {
  if (a >= b && a >= c)
    return a;
  else if (b >= a && b >= c)
    return b;
  else
    return c;
}
map<long long, long long> frequency(vector<long long> v) {
  map<long long, long long> m;
  for (long long i = 0; i < v.size(); i++) {
    if (m.find(v[i]) != m.end())
      m[v[i]]++;
    else {
      m.insert({v[i], 1});
    }
  }
  return m;
}
void solve() {
  long long a, b;
  cin >> a >> b;
  if (a == b)
    cout << "0\n";
  else if (a > b) {
    if (a % b != 0)
      cout << "-1\n";
    else {
      long long c = a / b;
      long long ans = 0;
      if (c % 2 == 1)
        ans = -1;
      else {
        while (c > 0) {
          if (c % 8 == 0)
            c = c / 8;
          else if (c % 4 == 0)
            c = c / 4;
          else if (c % 2 == 0)
            c = c / 2;
          else
            break;
          ans++;
        }
        if (c != 1) ans = -1;
      }
      cout << ans << endl;
    }
  } else {
    if (b % a != 0)
      cout << "-1\n";
    else {
      long long c = b / a;
      long long ans = 0;
      if (c % 2 == 1)
        ans = -1;
      else {
        while (c > 0) {
          if (c % 8 == 0)
            c = c / 8;
          else if (c % 4 == 0)
            c = c / 4;
          else if (c % 2 == 0)
            c = c / 2;
          else
            break;
          ans++;
        }
        if (c != 1) ans = -1;
      }
      cout << ans << endl;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long test;
  cin >> test;
  while (test--) solve();
  return 0;
}
