#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    if (a > b) swap(a, b);
    if (b % a) {
      puts("-1");
      continue;
    }
    long long r = b / a;
    int c = 0;
    while (r % 2 == 0) {
      r /= 2;
      c++;
    }
    if (r != 1) {
      puts("-1");
      continue;
    }
    int ans = (c / 3);
    int rest = c % 3;
    ans += rest / 2;
    rest = rest % 2;
    ans += rest;
    printf("%d\n", ans);
  }
  return 0;
}
