#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  long long a, b;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    int ans = 0;
    while (a > b) {
      if (a % 8 == 0 && a / 8 >= b)
        ans++, a /= 8;
      else if (a % 4 == 0 && a / 4 >= b)
        ans++, a /= 4;
      else if (a % 2 == 0 && a / 2 >= b)
        ans++, a /= 2;
      else {
        break;
      }
    }
    while (a < b) {
      if (a * 8 <= b)
        ans++, a *= 8;
      else if (a * 4 <= b)
        ans++, a *= 4;
      else if (a * 2 <= b)
        ans++, a *= 2;
      else {
        break;
      }
    }
    if (a != b)
      cout << "-1\n";
    else
      cout << ans << "\n";
  }
  return 0;
}
