#include <bits/stdc++.h>
using namespace std;
long long t, a, b, jum, tmp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  for (int rr = 0; rr < t; rr++) {
    cin >> a >> b;
    jum = 0;
    if (b > a) {
      swap(a, b);
    }
    tmp = a / b;
    if (tmp * b == a) {
      while (tmp % 2 == 0) {
        tmp /= 2;
        jum++;
      }
      if (tmp == 1) {
        cout << jum / 3 + (jum % 3 > 0) << '\n';
        continue;
      }
    }
    cout << -1 << '\n';
  }
}
