#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return (a ? gcd(b % a, a) : b);
}
long long int pow1(long long int a, long long int b, long long int MOD) {
  long long int ans = 1;
  while (b != 0) {
    if (b & 1) ans = (ans * a) % MOD;
    a = (a * a) % MOD;
    b = b / 2;
  }
  return ans;
}
long long int modInverse(long long int a, long long int p) {
  return pow1(a, p - 2, p);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    if (a == b)
      cout << "0\n";
    else if (a > b) {
      long long int c = 0;
      while (a != b) {
        if (a % 8 == 0 && a / 8 >= b) {
          a = a / 8;
          c++;
        } else if (a % 4 == 0 && a / 4 >= b) {
          a = a / 4;
          c++;
        } else if (a % 2 == 0 && a / 2 >= b) {
          a = a / 2;
          c++;
        } else
          break;
      }
      if (a != b)
        cout << "-1\n";
      else
        cout << c << "\n";
    } else {
      long long int c = 0;
      while (a != b) {
        if (8 * a <= b) {
          a = a * 8;
          c++;
        } else if (4 * a <= b) {
          a = a * 4;
          c++;
        } else if (2 * a <= b) {
          a = a * 2;
          c++;
        } else
          break;
      }
      if (a != b)
        cout << "-1\n";
      else
        cout << c << "\n";
    }
  }
}
