#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int a, b;
  cin >> a >> b;
  if (a == b) {
    cout << 0 << endl;
    return;
  }
  if (b > a) {
    long long int temp = a;
    a = b;
    b = temp;
  }
  if (a % b != 0) {
    cout << -1 << endl;
    return;
  }
  long long int n = a / b;
  if (n % 2 != 0) {
    cout << -1 << endl;
    return;
  }
  long long int ans = 0;
  while (n / 8 > 0 && n % 8 == 0) {
    ans++;
    n /= 8;
  }
  while (n / 4 > 0 && n % 4 == 0) {
    ans++;
    n /= 4;
  }
  while (n / 2 > 0 && n % 2 == 0) {
    ans++;
    n /= 2;
  }
  if (n > 1) {
    cout << -1 << endl;
    return;
  }
  cout << ans << endl;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
