#include <bits/stdc++.h>
using namespace std;
int first(long long int a, long long int b) {
  long long int i = 0;
  while (a != b) {
    int k = 3;
    if ((a & 1) != 1) {
      while ((a & 1) != 1 && k != 0 && a != b) {
        a = a >> 1;
        k--;
      }
    } else if ((a & 1) == 1 || a < b) {
      return -1;
    }
    i++;
  }
  return i;
}
int second(long long int a, long long int b) {
  long long int i = 0;
  while (a != b) {
    a = (a << 1) >= b ? a << 1
                      : ((a << 2) >= b     ? a << 2
                         : ((a << 3) <= b) ? a << 3
                                           : a << 2);
    if (a > b) {
      return -1;
    }
    i++;
  }
  return i;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    if (a > b) {
      cout << first(a, b) << endl;
    } else if (a == b) {
      cout << 0 << endl;
    } else {
      cout << second(a, b) << endl;
    }
  }
  return 0;
}
