#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int t, t1, t2, t3, t4, n, k, cnt;
  cin >> t;
  while (t--) {
    cnt = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0;
    cin >> n >> k;
    if ((n != k && n % 2 != 0 && k % 2 != 0)) {
      cout << "-1" << endl;
      continue;
    } else {
      if (n > k) {
        if (n % k != 0) {
          cout << "-1" << endl;
          continue;
        }
        if (n % k == 0 && (n / k) % 2 != 0) {
          cout << "-1" << endl;
          continue;
        }
      } else if (n < k) {
        if (k % n != 0) {
          cout << "-1" << endl;
          continue;
        } else if (k % n == 0 && (k / n) % 2 != 0) {
          cout << "-1" << endl;
          continue;
        }
      }
    }
    if (n > k) {
      t1 = n / k;
      t2 = log2(t1);
      t3 = pow(2, t2);
      if (t3 != t1) {
        cout << "-1" << endl;
        continue;
      } else
        cnt = (t2 / 3) + (t2 % 3) / 2 + (t2 % 3) % 2;
    } else if (k > n) {
      t1 = k / n;
      t2 = log2(t1);
      t3 = pow(2, t2);
      if (t3 != t1) {
        cout << "-1" << endl;
        continue;
      } else
        cnt = (t2 / 3) + (t2 % 3) / 2 + (t2 % 3) % 2;
    }
    cout << cnt << endl;
  }
}
