#include <bits/stdc++.h>
using namespace std;
int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};
void runcase() {
  long long a, b;
  cin >> a >> b;
  if (b > a) swap(a, b);
  long long p = a / b;
  if (a == b) {
    cout << 0 << endl;
    return;
  }
  long long count = 0;
  long long q = p;
  while (q) {
    if (q % 2 == 0 || q == 1)
      q /= 2;
    else {
      cout << -1 << endl;
      return;
    }
  }
  if (a % b == 0 && p % 2 == 0) {
    while (p % 8 == 0 && p != 0) {
      count++;
      p /= 8;
    }
    while (p % 4 == 0 && p != 0) {
      count++;
      p /= 4;
    }
    while (p % 2 == 0 && p != 0) {
      count++;
      p /= 2;
    }
    if (count == 0)
      cout << -1 << endl;
    else
      cout << count << endl;
    return;
  } else {
    cout << -1 << endl;
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) runcase();
}
