#include <bits/stdc++.h>
using namespace std;
void printArray(long long arr[], long long size) {
  for (int i = 0; i < size; i++) cout << arr[i] << " ";
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long p, c = 0, k = 0;
    if (a % b == 0 || b % a == 0) {
      if (a != b) {
        if (a > b)
          p = a / b;
        else
          p = b / a;
        while (p != 1) {
          if (p % 8 == 0) {
            p /= 8;
            c++;
          } else if (p % 4 == 0) {
            p /= 4;
            c++;
          } else if (p % 2 == 0) {
            p /= 2;
            c++;
          } else {
            k = 1;
            break;
          }
        }
        if (k == 1)
          cout << "-1";
        else
          cout << c;
      } else
        cout << 0;
    } else
      cout << "-1";
    cout << '\n';
  }
  return 0;
}
