#include <stdio.h>
// Function to find minimum operations to make A equal to B
int minOperations(int A, int B) {
int operations = 0;
// Keep applying operations until A becomes equal to or greater than B
while (A < B) {
// If doubling A makes it greater than or equal to B, then double it
if (A * 2 >= B) {
A *= 2;
}
// Otherwise, increment A
else {
A++;
}
operations++; // Increment the count of operations
}
return operations;
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
int A, B;
scanf("%d %d", &A, &B);
printf("%d\n", minOperations(A, B));
}
return 0;
}