#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int test = 1;
  cin >> test;
  while (test--) {
    long long int a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    long long int count = 0;
    while (a > b) {
      if (a % 2 == 0) {
        a /= 2;
        count++;
      } else
        break;
    }
    if (a == b) {
      if (count % 3 == 0)
        cout << count / 3 << endl;
      else
        cout << (count / 3) + 1 << endl;
    } else
      cout << -1 << endl;
  }
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
