#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    long long temp = max(a, b);
    if (a > b) swap(a, b);
    long long cnt1 = 0;
    while (a % 2 == 0) {
      cnt1++;
      a /= 2;
    }
    long long cnt2 = 0;
    while (b % 2 == 0) {
      cnt2++;
      b /= 2;
    }
    if (a != b) {
      cout << -1 << endl;
      continue;
    }
    long long d = abs(cnt2 - cnt1);
    long long ans = 0;
    if (d >= 3) {
      ans += d / 3;
      d %= 3;
    }
    if (d >= 2) {
      ans += d / 2;
      d %= 2;
    }
    if (d >= 1) {
      ans += d / 1;
      d %= 1;
    }
    cout << ans << endl;
  }
  return 0;
}
