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