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