#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    unsigned long long int a, b;
    cin >> a >> b;
    if (a == b) {
      cout << "0" << endl;
      continue;
    }
    if (b > a) {
      if (b % a != 0) {
        cout << "-1" << endl;
        continue;
      }
      int i = 0;
      unsigned long long int c = b / a;
      while (c % 2 == 0) {
        i++;
        c = c / 2;
      }
      long long int x, y, z;
      if (c == 1) {
        x = i / 3;
        y = (i % 3) / 2;
        z = i - x * 3 - y * 2;
        cout << x + y + z << endl;
      } else
        cout << "-1" << endl;
    } else {
      if (a % b != 0) {
        cout << "-1" << endl;
        continue;
      }
      int i = 0;
      unsigned long long int c = a / b;
      while (c % 2 == 0) {
        i++;
        c = c / 2;
      }
      long long int x, y, z;
      if (c == 1) {
        x = i / 3;
        y = (i % 3) / 2;
        z = i - x * 3 - y * 2;
        cout << x + y + z << endl;
      } else
        cout << "-1" << endl;
    }
  }
  return 0;
}
