#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b;
  cin >> a >> b;
  if (a < b) {
    long long x = a;
    a = b;
    b = x;
  }
  if (a % b) {
    cout << "-1\n";
    return;
  }
  a = a / b;
  long long c = 0;
  while (a > 1) {
    if (a % 2) {
      cout << "-1\n";
      return;
    }
    c++;
    a /= 2;
  }
  long long x = c / 3, y = (c - x * 3) / 2, z = c - x * 3 - y * 2;
  cout << x + y + z << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
