#include <bits/stdc++.h>
const long long m = 1e9 + 7;
using namespace std;
void FIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int32_t main() {
  FIO();
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (max(a, b) % min(a, b) != 0)
      cout << "-1\n";
    else {
      long long p = max(a, b) / min(a, b), cnt = 0;
      while (p > 1) {
        if (p % 8 == 0) {
          p /= 8;
          cnt++;
        } else if (p % 4 == 0) {
          p /= 4;
          cnt++;
        } else if (p % 2 == 0) {
          p /= 2;
          cnt++;
        } else
          break;
      }
      if (p != 1)
        cout << "-1\n";
      else
        cout << cnt << "\n";
    }
  }
  return 0;
}
