#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long a;
    cin >> a;
    long long b;
    cin >> b;
    if (a == b) {
      cout << 0 << "\n";
      continue;
    }
    if (b > a) {
      long long t = a;
      a = b;
      b = t;
    }
    if (a % b) {
      cout << -1 << "\n";
      continue;
    }
    long double m = 1.0 * a / b;
    m = log2(m);
    if (ceil(m) != floor(m)) {
      cout << -1 << "\n";
      continue;
    }
    long long ans = ceil(1.0 * m / 3);
    cout << ans << "\n";
  }
}
