#include <stdio.h>
int main() {
int t, times;
long long x, y;
scanf("%d\n", &t);
while (t--) {
scanf("%lld %lld", &x, &y);
times = 0;
while (x != y) {
if (x & ~y) {
x >>= 1;
} else {
x |= y;
}
++times;
}
printf("%d\n", times);
}
return 0;
}

京公网安备 11010502036488号