#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, r, a, b, a1, b1, f, c;
  cin >> t;
  while (t--) {
    int c = 0;
    cin >> a1 >> b1;
    b = max(a1, b1);
    a = min(a1, b1);
    r = b / a + b % a;
    while (r % 8 == 0) {
      r = r / 8;
      c++;
    }
    while (r % 4 == 0) {
      r = r / 4;
      c++;
    }
    while (r % 2 == 0) {
      r = r / 2;
      c++;
    }
    if (r != 1 || b % a != 0)
      cout << "-1" << endl;
    else
      cout << c << endl;
  }
}
