#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t, n, b, a, x, ans;
  cin >> t;
  while (t--) {
    cin >> n >> b;
    if (n == b) {
      cout << 0 << "\n";
      continue;
    }
    if (n < b) {
      a = n;
      ans = 0;
      if (b % a != 0) {
        cout << -1 << "\n";
        continue;
      }
      x = b / a;
      while (x % 8 == 0) {
        x /= 8;
        ans++;
      }
      while (x % 4 == 0) {
        x /= 4;
        ans++;
      }
      while (x % 2 == 0) {
        x /= 2;
        ans++;
      }
      if (x != 1) {
        cout << -1 << "\n";
        continue;
      }
      cout << ans << "\n";
    }
    if (n > b) {
      a = n;
      ans = 0;
      if (a % b != 0) {
        cout << -1 << "\n";
        continue;
      }
      x = a / b;
      while (x % 8 == 0) {
        x /= 8;
        ans++;
      }
      while (x % 4 == 0) {
        x /= 4;
        ans++;
      }
      while (x % 2 == 0) {
        x /= 2;
        ans++;
      }
      if (x != 1) {
        cout << -1 << "\n";
        continue;
      }
      cout << ans << "\n";
    }
  }
}
