Transit
Output: Standard Output (stdout)
Memory limit: 16 megabytes
Time limit: 1.0 seconds
After a busy day at training camp, LiChao is tired after doing too many DP optimization problems. Having mastered Lagrangian Relaxation, he brings up CHT and jokes about it being for toddlers. However, as soon as the word Comp Geo
flew out of the professor's mouth, he yeets himself out the window. After getting back up, he decides to head home, traveling from station A to station B, using the metro system, which conveniently just had an upgrade that promises excellence and efficiency through developing trains capable of greater warps.
All types of trains start at station 1.
- Type 0 trains can warp between 1 and 2, 2 and 3, 3 and 4, and so on.
- Type 1 trains can warp between 1 and 3, 3 and 5, 5 and 7, and so on.
- Type 2 trains can warp between 1 and 5, 5 and 9, 9 and 13, and so on.
In summary, Type x trains can warp between 1 + n \cdot 2^x and 1 + (n+1) \cdot 2^x, for n \geq 0. You can assume there are an infinite number of types of trains.
Since LiChao injured himself during his escape from Comp Geo, help him write a program to calculate the minimum warps it takes to get home, plus as a bonus, calculate the number of types of trains he will ride on that trip.
Note
- Trains do not go backwards as the world would collapse, thus it's impossible to warp to a station with a smaller index.
- This problem may not be fully solvable in an interpretered language, a compiled language such as C++ is recommended.
- Make sure to use a 64-bit integer type to avoid integer overflow.
Input
The first line will contain N, the number of queries.
The following N lines will each contain 2 space-separated numbers A_i and B_i.
Output
Output N lines, each containing 2 space-separated numbers W_i and V_i, the minimum number of warps needed to get home and the number of types of trains LiChao will ride.
Constraints
- 1 \leq N \leq 10^6
- 1 \leq A_i < B_i \leq 10^{18}
- 1 \leq W_i \leq 10
Subtasks
- Subtask 1 (30%): N \leq 100, A_i < B_i \leq 100
- Subtask 2 (20%): N \leq 10^4, A_i = 1, B_i \leq 10^5
- Subtask 3 (30%): N \leq 10^5, A_i < B_i \leq 10^9
- Subtask 4 (10%): A_i = 1
- Subtask 5 (10%): No further constraints
Sample Explanation
- In the first case, LiChao can warp from station 9 straight to station 17 using a type 4 train. Taking 1 warp and using 1 type of train.
- In the second case, LiChao can first warp from station 4 to station 5 using a type 0 train, then from station 5 to station 9 using a type 2 train, then finally from station 9 to station 10 using a type 0 train again. Taking 3 warps and using 2 types of trains (type 0 and type 2).
-
Sample Input 1
2 9 17 4 10
Sample Output 1
1 1 3 2
-
Sample Input 2
2 1 16 1 342
Sample Output 2
4 4 5 5