#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
  ll a, b;
  cin >> a >> b;
  if (a == b) {
    cout << 0 << endl;
    return;
  }
  if (a < b) swap(a, b);
  if (a % b) {
    cout << -1 << endl;
    return;
  }
  a /= b;
  ll p = log2(a);
  if (a == (1LL << p))
    cout << (p + 2) / 3 << endl;
  else
    cout << -1 << endl;
  return;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
