#include <bits/stdc++.h>
using namespace std;
template <typename F, typename S>
ostream &operator<<(ostream &os, const pair<F, S> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  typename vector<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  typename set<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename F, typename S>
ostream &operator<<(ostream &os, const map<F, S> &v) {
  os << "[";
  typename map<F, S>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
struct CustomCompare {
  bool operator()(pair<int64_t, int64_t> &a, pair<int64_t, int64_t> &b) {
    if (a.second == b.second) return a.first < b.first;
    return a.second < b.second;
  }
};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int64_t t = 1;
  cin >> t;
  while (t--) {
    int64_t a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    if (a > b) swap(a, b);
    if (b % a != 0) {
      cout << -1 << endl;
      continue;
    }
    int64_t x = b / a;
    int64_t bits = __builtin_popcountll(x);
    if (bits == 1) {
      int64_t c = 0;
      for (int64_t i = 0; i < 64; i++) {
        if ((int64_t)x & ((int64_t)1 << (int64_t)i)) c = i;
      }
      int64_t ans = c / 3;
      c -= (c / 3) * 3;
      ans += (c / 2);
      c -= (c / 2) * 2;
      ans += (c / 1);
      cout << ans << endl;
    } else {
      cout << -1 << endl;
      continue;
    }
  }
  return 0;
}
