#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a == b)
      cout << 0 << endl;
    else {
      int count = 0;
      if (b > a) {
        while (a < b) {
          a *= 2;
          count++;
        }
        if (a == b) {
          int x = count % 3;
          if (x == 2) x = 1;
          cout << (count / 3) + x << endl;
        } else {
          cout << -1 << endl;
        }
      } else {
        int count = 0;
        while (a > b) {
          if (a % 2 == 0) {
            a /= 2;
            count++;
          } else
            break;
        }
        if (a == b) {
          int x = count % 3;
          if (x == 2) x = 1;
          cout << (count / 3) + x << endl;
        } else {
          cout << -1 << endl;
        }
      }
    }
  }
}
