#include using namespace std; int main() { int testcase; cin >> testcase; while (testcase--) { long long int a, b, temp, count = 0; bool flag = false; cin >> a >> b; if (a == b) { cout << 0; } else if (a > b) { if (a % b == 0) { temp = a / b; while (temp != 0) { if (temp % 2 == 0) { temp = temp / 2; count++; } else if (temp == 1) { //count++; break; } else { cout << -1; flag = true; break; } } int temp1 = count % 3; int temp2 = temp1 % 2; int result = count / 3 + temp1 / 2 + temp2; if(flag == false) { cout << result; } } else { cout << -1; } } else if (a < b) { if (b % a == 0) { temp = b / a; while (temp != 0) { if (temp % 2 == 0) { temp = temp / 2; count++; } else if (temp == 1) { //count++; break; } else { cout << -1; flag = true; break; } } int temp1 = count % 3; int temp2 = temp1 % 2; int result = count / 3 + temp1 / 2 + temp2; if (flag == false) cout << result; } else { cout << -1; } } cout << endl; } }