#include <bits/stdc++.h>
using namespace std;
long long r(long long a) {
  long long i = 0;
  while (a % 2 == 0) {
    a /= 2;
    ++i;
  }
  return i;
}
void one_case() {
  long long a, b;
  cin >> a >> b;
  auto ra = r(a);
  auto rb = r(b);
  a /= (1ll << ra);
  b /= (1ll << rb);
  if (a != b) {
    cout << "-1\n";
    return;
  }
  cout << (abs(ra - rb) + 2) / 3 << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int t = 1;
  cin >> t;
  while (t--) {
    one_case();
  }
  return 0;
}
