#include <bits/stdc++.h>
using namespace std;
void ans() {
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long x = a / b;
    long long y = b / a;
    long long c = 0;
    long long f = 0;
    if (a == b) {
      cout << 0;
    } else if (a % b == 0) {
      if (a / b == 8 || a / b == 4 || a / b == 2) {
        cout << 1;
      } else if ((a / b) % 2 == 0 || (a / b) % 4 == 0 || (a / b) % 8 == 0) {
        while (x != 1) {
          if (x % 8 == 0) {
            c++;
            x /= 8;
          } else if (x % 4 == 0) {
            c++;
            x /= 4;
          } else if (x % 2 == 0) {
            c++;
            x /= 2;
          } else {
            f = 1;
            break;
          }
        }
        if (f) {
          cout << -1;
        } else {
          cout << c;
        }
      } else {
        cout << -1;
      }
    } else if (b % a == 0) {
      if (y == 8 || y == 4 || y == 2) {
        cout << 1;
      } else if (y % 2 == 0 || y % 4 == 0 || y % 8 == 0) {
        while (y != 1) {
          if (y % 8 == 0) {
            c++;
            y /= 8;
          } else if (y % 4 == 0) {
            c++;
            y /= 4;
          } else if (y % 2 == 0) {
            c++;
            y /= 2;
          } else {
            f = 1;
            break;
          }
        }
        if (f) {
          cout << -1;
        } else {
          cout << c;
        }
      } else {
        cout << -1;
      }
    } else {
      cout << -1;
    }
    cout << endl;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ans();
  return 0;
}
