#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    if (a > b) {
      if (a % b != 0)
        cout << -1 << endl;
      else {
        long long op = 0;
        long long n = a / b;
        while (n % 8 == 0 && n > 1) {
          n /= 8;
          op++;
        }
        while (n % 4 == 0 && n > 1) {
          n /= 4;
          op++;
        }
        while (n % 2 == 0 && n > 1) {
          n /= 2;
          op++;
        }
        if (op == 0 || n != 1) op = -1;
        cout << op << endl;
      }
    } else {
      if (b % a != 0)
        cout << -1 << endl;
      else {
        long long op = 0;
        long long n = b / a;
        while (n % 8 == 0 && n > 1) {
          n /= 8;
          op++;
        }
        while (n % 4 == 0 && n > 1) {
          n /= 4;
          op++;
        }
        while (n % 2 == 0 && n > 1) {
          n /= 2;
          op++;
        }
        if (op == 0 || n != 1) op = -1;
        cout << op << endl;
      }
    }
  }
  return 0;
}
