#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (b < a) swap(a, b);
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    long long c = b / a, ans = 0;
    if (b % a == 0 && ((c & c - 1) == 0)) {
      while (b > a) {
        b /= 8;
        ans++;
      }
      cout << ans << endl;
    } else
      cout << -1 << endl;
  }
  return 0;
}
