#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    long long a, b, ans = -1, k, j = 0;
    cin >> a >> b;
    if (a == b) {
      ans = 0;
    } else {
      if (a > b) {
        k = a / b;
        if (a % b == 0 && __builtin_popcountll(k) == 1) {
          while (k != 1) {
            k = k / 2;
            j++;
          }
          ans = ceil((double)j / 3);
        }
      } else {
        k = b / a;
        if (b % a == 0 && __builtin_popcountll(k) == 1) {
          while (k != 1) {
            k = k / 2;
            j++;
          }
          ans = ceil((double)j / 3);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
