#include <bits/stdc++.h>
using namespace std;
long long int getval(unsigned long long a, unsigned long long b) {
  if (b == a) return 0;
  unsigned long long cnt = 0;
  while (a >= b * 8) {
    b = b * 8;
    cnt++;
    if (a == b) return cnt;
  }
  while (a >= b * 4) {
    b = b * 4;
    cnt++;
    if (a == b) return cnt;
  }
  while (a >= b * 2) {
    b = b * 2;
    cnt++;
    if (a == b) return cnt;
  }
  return -1;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    unsigned long long a, b;
    cin >> a >> b;
    if (a > b)
      cout << getval(a, b) << endl;
    else
      cout << getval(b, a) << endl;
  }
  return 0;
}
