#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long a;
    cin >> a;
    long long b;
    cin >> b;
    if (b >= a) {
      if (b % a == 0 && pow(2, (long long)log2(b / a)) == b / a) {
        if ((long long)(log2(b / a)) % 3 == 0) {
          cout << (long long)log2(b / a) / 3 << endl;
        } else {
          cout << (long long)(1 + (log2(b / a) / 3)) << endl;
        }
      } else {
        cout << -1 << endl;
      }
    } else {
      if (a % b == 0 && pow(2, (long long)log2(a / b)) == a / b) {
        if ((long long)(log2(a / b)) % 3 == 0) {
          cout << (long long)log2(a / b) / 3 << endl;
        } else {
          cout << (long long)(1 + (log2(a / b) / 3)) << endl;
        }
      } else {
        cout << -1 << endl;
      }
    }
  }
  return 0;
}
