#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  cin.sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    long long ans = 0;
    while (a * 8 <= b) {
      a *= 8;
      ans++;
    }
    while (a * 4 <= b) {
      a *= 4;
      ans++;
    }
    while (a * 2 <= b) {
      a *= 2;
      ans++;
    }
    if (a == b) {
      cout << ans << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
}
