Xingqiu's Joke
시간 제한2초메모리 제한1024 MB
두 정수 a와 b가 주어질 때, 둘 모두에 1을 더하거나 빼거나 공통 소인수로 나누는 연산만으로 a 또는 b가 1이 되게 하는 최소 횟수를 구한다.
문제
Once again, Xingqiu hides Chongyun's ice cream into a box with a strange lock. Liyue's summer has been always very hot and Chongyun suffers more because of his excessive yang (positive) energy, so he needs that ice cream desperately.

Pixiv ID: 86787400
There are two integers and on the lock. Chongyun can perform the following three types of operations any number of times:
- Minus from both and ;
- Plus to both and ;
- Divide both and by one of their common prime factor (that is to say, divide them by a prime where and are both divisible by ).
The box will be unlocked if either or or both become . To help Chongyun gets the ice cream back as quickly as possible, please tell him the minimum number of operations needed to unlock the box.
입력
There are multiple test cases. The first line of the input contains an integer () indicating the number of test cases. For each test case:
The first and only line contains two integers and (, ).
출력
For each test case output one line containing one integer indicating the minimum number of operations to make or or both equal .
힌트
For the first sample test case, the optimal way is .
For the second sample test case, the optimal way is to apply the first type of operation times.
For the third sample test case, the optimal way is .
For the fourth sample test case, the optimal way is .