#include <bits/stdc++.h>
using namespace std;
long int operations(long long int x, long long int y) {
  if (y % x != 0) return -1;
  long long int num = y / x;
  long int op = 0;
  while (num != 1) {
    if (num % 8 == 0) {
      op++;
      num /= 8;
    } else if (num % 4 == 0) {
      op++;
      num /= 4;
    } else if (num % 2 == 0) {
      op++;
      num /= 2;
    } else
      return -1;
  }
  return op;
}
int main() {
  int t;
  cin >> t;
  long long int a, b;
  while (t--) {
    cin >> a >> b;
    if (b > a)
      cout << operations(a, b) << endl;
    else
      cout << operations(b, a) << endl;
  }
  return 0;
}
