#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long ans = 0;
    if (b >= a) {
      while (b > a) {
        a *= 2;
        ans++;
      }
      if (b == a) {
        ans = (ans / 3) + ((ans % 3) / 2) + ((ans % 3) % 2);
        cout << ans << "\n";
      } else
        cout << -1 << "\n";
    } else {
      while (b < a) {
        if (a % 2 == 0) {
          a /= 2;
          ans++;
        } else
          break;
      }
      if (b == a) {
        ans = (ans / 3) + ((ans % 3) / 2) + ((ans % 3) % 2);
        cout << ans << "\n";
      } else
        cout << -1 << "\n";
    }
  }
  return 0;
}
