#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    int c = 0;
    if (a < b) {
      while (a < b) {
        a <<= 1;
        c++;
      }
    } else {
      while (a > b && !(a & 1)) {
        a >>= 1;
        c++;
      }
    }
    if (a == b) {
      int ans = c / 3;
      c = c % 3;
      ans += c / 2;
      c = c % 2;
      ans += c;
      cout << ans << endl;
    } else
      cout << "-1" << endl;
  }
  return 0;
}
