#include <bits/stdc++.h>
using namespace std;
int getr(long long int a) {
  while (a % 2 == 0) {
    a = a / 2;
  }
  return a;
}
int func(long long int a, long long int b) {
  long long int count, m, n;
  if (a == b) {
    return 0;
  } else if (a % b != 0) {
    return -1;
  } else if (getr(a) != getr(b)) {
    return -1;
  } else {
    count = a / b;
    m = log2(count);
    if (ceil(log2(count)) == floor(log2(count))) {
      if (m % 3 == 0) {
        n = m / 3;
      } else {
        n = m / 3 + 1;
      }
      return n;
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    if (a >= b) {
      cout << func(a, b) << endl;
    } else {
      cout << func(b, a) << endl;
    }
  }
  return 0;
}
