#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 30, Mod = 1e9 + 7;
const long long SQ = 330;
long long f(long long x) {
  long long ans = 61;
  for (int a = 0; a < 61; a++) {
    for (int b = 0; b < 61; b++) {
      long long c = x - a * 3 - b * 2;
      if (c < 0) continue;
      ans = min(ans, a + b + c);
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long q;
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    if (a % b) {
      cout << "-1\n";
      continue;
    }
    long long n = a / b;
    long long is = 0;
    for (int i = 0; i < 61; i++) {
      if ((1ll << i) == n) {
        is = 1;
        cout << f(i) << '\n';
        break;
      }
    }
    if (!is) cout << "-1\n";
  }
}
