#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    int ctr1 = 0, ctr2 = 0;
    if (m > n) swap(m, n);
    while (n % 2 == 0) {
      ctr1++;
      n = n / 2;
    }
    while (m % 2 == 0) {
      ctr2++;
      m = m / 2;
    }
    int flag = 0;
    if (m != n) flag = 1;
    int ans = abs(ctr1 - ctr2);
    ans = ceil((double(ans) / 3));
    if (flag == 1)
      cout << "-1" << endl;
    else
      cout << ans << endl;
  }
}
