#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18L + 5;
const int inf = 1e9 + 5;
struct comp {
  bool operator()(pair<int, int> p1, pair<int, int> p2) {
    if (p1.first < p2.first) return false;
    if (p2.first < p1.first) return true;
    return p1.second < p2.second;
  };
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test;
  cin >> test;
  while (test--) {
    long long a, b;
    cin >> a >> b;
    if (a > b) {
      if (a % b == 0) {
        long long x = a / b;
        long long ans = log2(x);
        if ((pow(2, ans) * b) == a) {
          long long res = 0, ret = ans / 3;
          ans = ans - ret * (3);
          res += ret;
          ret = ans / 2;
          ans = ans - ret * 2;
          res += ret;
          res += ans;
          cout << res << endl;
        } else
          cout << -1 << endl;
      } else {
        cout << -1 << endl;
      }
    } else {
      if (b % a == 0) {
        long long x = b / a;
        long long ans = log2(x);
        if ((pow(2, ans) * a) == b) {
          long long res = 0, ret = ans / 3;
          ans = ans - ret * (3);
          res += ret;
          ret = ans / 2;
          ans = ans - ret * 2;
          res += ret;
          res += ans;
          cout << res << endl;
        } else
          cout << -1 << endl;
      } else {
        cout << -1 << endl;
      }
    }
  }
  return 0;
}
