#include <bits/stdc++.h>
using namespace std;
unsigned cb(unsigned long long int number) {
  return (long long int)log2(number) + 1;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    if (a % b) {
      cout << -1 << "\n";
    } else {
      long long int ans = 0;
      long long int t = a / b;
      while (t % 8 == 0) t = t / 8, ans++;
      while (t % 4 == 0) t = t / 4, ans++;
      while (t % 2 == 0) t = t / 2, ans++;
      if (t == 1) {
        cout << ans << "\n";
      } else {
        cout << -1 << "\n";
      }
    }
  }
  return 0;
}
