#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    if (a % b != 0) {
      cout << -1 << "\n";
      continue;
    }
    long long int val = a / b, cnt = 0;
    while (val % 2 == 0) {
      val /= 2;
      cnt++;
    }
    if (val != 1)
      cout << -1 << "\n";
    else {
      long long int v = ceil(cnt / 3.0);
      cout << v << "\n";
    }
  }
}
