#include <bits/stdc++.h>
using namespace std;
int64_t t, a, b;
int64_t Check(int64_t k) {
  int64_t _t = 1;
  for (int i = 0; i <= 63; i++) {
    if ((_t << int64_t(i)) == k) return i;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a == b) {
      cout << 0 << '\n';
      continue;
    }
    if (a < b) swap(a, b);
    if (a % b) {
      cout << -1 << '\n';
      continue;
    }
    int64_t k = a / b;
    k = Check(k);
    if (k) {
      int64_t a1 = k / 3;
      k -= a1 * 3;
      int64_t a2 = k / 2;
      k -= a2 * 2;
      cout << a1 + a2 + k << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
  return 0;
}
