#include <bits/stdc++.h>
using namespace std;
void print(long long cnt, bool ok) {
  if (ok)
    cout << cnt / 3 + (cnt % 3) / 2 + (cnt % 3) % 2 << endl;
  else
    cout << "-1" << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b, cnt = 0;
    cin >> a >> b;
    if (a > b) {
      bool ok = false;
      while (a) {
        if (!(a & 1))
          a = a >> 1;
        else
          break;
        cnt++;
        if (a == b) {
          ok = true;
          break;
        }
      }
      print(cnt, ok);
    } else if (a < b) {
      bool ok = false;
      while (a <= b) {
        a = a << 1;
        cnt++;
        if (a == b) {
          ok = true;
          break;
        }
      }
      print(cnt, ok);
    } else
      cout << "0" << endl;
  }
  return 0;
}
