#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long N = 100000;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename first, typename second>
ostream &operator<<(ostream &os, const pair<first, second> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename first, typename second>
ostream &operator<<(ostream &os, const map<first, second> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
map<long long, long long> dp;
long long solve1(long long a, long long b) {
  if (a < b) return LONG_MAX / 10;
  if (a == b) return 0;
  long long res = LONG_MAX / 10;
  if (dp.find(a) != dp.end()) {
    return dp[a];
  }
  if (a % 2 == 0) {
    res = min(res, 1 + solve1(a / 2, b));
  }
  if (a % 4 == 0) {
    res = min(res, 1 + solve1(a / 4, b));
  }
  if (a % 8 == 0) {
    res = min(res, 1 + solve1(a / 8, b));
  }
  dp[a] = res;
  return res;
}
long long solve2(long long a, long long b) {
  if (b < a) return LONG_MAX / 10;
  if (a == b) return 0;
  long long res = LONG_MAX / 10;
  if (dp.find(a) != dp.end()) {
    return dp[a];
  }
  res = min(res, 1 + solve2(a * 2, b));
  res = min(res, 1 + solve2(a * 4, b));
  res = min(res, 1 + solve2(a * 8, b));
  dp[a] = res;
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long a;
    cin >> a;
    long long b;
    cin >> b;
    if (a > b) {
      long long res = solve1(a, b);
      if (res == LONG_MAX / 10) res = -1;
      cout << res << "\n";
    } else {
      long long res = solve2(a, b);
      if (res == LONG_MAX / 10) res = -1;
      cout << res << "\n";
    }
    dp.clear();
  }
  return 0;
}
