#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b;
  cin >> a >> b;
  long long a1 = a, b1 = b;
  long long ac = 0, bc = 0;
  while (a1 % 2 == 0) {
    a1 /= 2;
    ac++;
  }
  while (b1 % 2 == 0) {
    b1 /= 2;
    bc++;
  }
  if (a1 == b1) {
    long long m = max(ac, bc);
    long long n = min(ac, bc);
    long long d = m - n;
    long long ans = d / 3;
    d %= 3;
    ans += d / 2;
    d %= 2;
    ans += d;
    cout << ans << endl;
  } else {
    cout << -1 << endl;
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
