#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
template <typename T>
void db(T x) {
  debug() << ">>> " << x;
}
template <typename T>
void db(T x, T y) {
  debug() << ">>> " << x << " , " << y;
}
template <typename T>
void db(T x, T y, T z) {
  debug() << ">>> " << x << " , " << y << " , " << z;
}
template <typename T>
void db(T x, T y, T z, T a) {
  debug() << ">>> " << x << " , " << y << " , " << z << " , " << a;
}
const long long xx = 2e5;
const long long Mod = 1e9 + 7;
const long long inf = 1e18;
const long long Maxn = 20010;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    long long cnt = 0;
    bool ok = false;
    while (b >= a) {
      if (a == b) {
        ok = true;
        break;
      }
      if (b % 8 == 0 && b / 8 >= a)
        b /= 8;
      else if (b % 4 == 0 && b / 4 >= a)
        b /= 4;
      else if (b % 2 == 0 && b / 2 >= a)
        b /= 2;
      else
        break;
      cnt++;
    }
    if (ok) {
      cout << cnt << '\n';
    } else
      cout << -1 << '\n';
  }
}
