#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  for (int tks = 0; tks < t; ++tks) {
    long long int a, b;
    cin >> a >> b;
    int cnt = 0;
    bool ok = true;
    if (a > b) {
      while (a > b) {
        b <<= 1;
        ++cnt;
      }
    } else {
      while (a < b) {
        a <<= 1;
        ++cnt;
      }
    }
    if (a != b) {
      ok = false;
    }
    int cm3 = cnt % 3;
    int cm2 = cm3 % 2;
    int rtn = cnt / 3 + cm3 / 2 + cm2;
    if (ok) {
      cout << rtn << '\n';
    } else {
      cout << "-1\n";
    }
  }
}
