Eddy Walker
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Eddy likes to walk around. Especially, he likes to walk in a loop called "Infinite loop". But, actually, it's just a loop with finite length(Anyway, the name doesn't matter). Eddy can walk in a fixed length. He finds that it takes him N steps to walk through the loop a cycle. Then, he puts N marks on the "Infinite loop" labeled with , where i and i+1 are a step away each other, so as 0 and N-1. After that, Eddy stands on the mark labeled 0 and start walking around. For each step, Eddy will independently uniformly randomly choose to move forward or backward. If currently Eddy is on the mark labeled i, he will on the mark labeled i+1 if move forward or i-1 if move backward. If Eddy is on the mark labeled N-1 and moves forward, he will stand on the mark labeled 0. If Eddy is on the mark labeled 0 and moves backward, he will stand on the mark labeled N-1.

Although, Eddy likes to walk around. He will get bored after he reaches each mark at least once. After that, Eddy will pick up all the marks, go back to work and stop walking around.

You, somehow, notice the weird convention Eddy is doing. And, you record T scenarios that Eddy walks around. For i-th scenario, you record two numbers N_i, M_i, where N_i tells that in the i-th scenario, Eddy can walk through the loop a cycle in exactly N_i steps(Yes! Eddy can walk in different fixed length for different day.). While M_i tells that you found that in the i-th scenario, after Eddy stands on the mark labeled M_i, he reached all the marks.

However, when you review your records, you are not sure whether the data is correct or even possible. Thus, you want to know the probability that those scenarios will happen. 

输入描述:

The first line of input contains an integers T.
Following T lines each contains two space-separated integers N_i and M_i.



输出描述:

Output T lines each contains an integer representing the probability that first i scenarios will happen sequentially.
you should output the number module .
Suppose the probability is , the desired output will be
示例1

输入

复制
3
1 0
2 1
3 0

输出

复制
1
1
0