#561
Unrated
Searching for Soulmates
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John's cows each want to find their soulmate -- another cow with similar characteristics with whom they are maximally compatible. Each cow's personality is described by an integer pip_i (1pi10181 \leq p_i \leq 10^{18}). Two cows with the same personality are soulmates. A cow can change her personality via a "change operation" by multiplying by 22, dividing by 22 (if pip_i is even), or adding 11.

Farmer John initially pairs his cows up in an arbitrary way. He is curious how many change operations would be needed to make each pair of cows into soulmates. For each pairing, decide the minimum number of change operations the first cow in the pair must make to become soulmates with the second cow.

입력

The first line contains NN (1N101\le N\le 10), the number of pairs of cows. Each of the remaining NN lines describes a pair of cows in terms of two integers giving their personalities. The first number indicates the personality of the cow that must be changed to match the second.

출력

Please write NN lines of output. For each pair, print the minimum number of operations required for the first cow to make her personality match that of the second.

예제 입력 1

6
31 13
12 8
25 6
10 24
1 1
997 120

예제 출력 1

8
3
8
3
0
20

점수

Test cases 1-4 satisfy pi105p_i \le 10^5. Test cases 5-12 satisfy no additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.