codeforces#P1311A. Add Odd or Subtract Even
Add Odd or Subtract Even
Description
You are given two positive integers and .
In one move, you can change in the following way:
- Choose any positive odd integer () and replace with ;
- choose any positive even integer () and replace with .
You can perform as many such operations as you want. You can choose the same numbers and in different moves.
Your task is to find the minimum number of moves required to obtain from . It is guaranteed that you can always obtain from .
You have to answer independent test cases.
The first line of the input contains one integer () — the number of test cases.
Then test cases follow. Each test case is given as two space-separated integers and ().
For each test case, print the answer — the minimum number of moves required to obtain from if you can perform any number of moves described in the problem statement. It is guaranteed that you can always obtain from .
Input
The first line of the input contains one integer () — the number of test cases.
Then test cases follow. Each test case is given as two space-separated integers and ().
Output
For each test case, print the answer — the minimum number of moves required to obtain from if you can perform any number of moves described in the problem statement. It is guaranteed that you can always obtain from .
Samples
Note
In the first test case, you can just add .
In the second test case, you don't need to do anything.
In the third test case, you can add two times.
In the fourth test case, you can subtract and add .
In the fifth test case, you can just subtract .