C. Cirno and the Math Problem
time limit per test
3 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Cirno has two integers $$$n$$$ and $$$m$$$, and she is counting the number of integer arrays $$$b = (b_1, b_2, \ldots, b_n)$$$ such that

  • $$$1 \le b_i \le m$$$ for every $$$1 \le i \le n$$$;
  • $$$b_i \lt b_{i+1}$$$ for every $$$1 \le i \lt n$$$;
  • $$$\gcd(b_i, b_{i+1}) = 1$$$$$$^{\text{∗}}$$$ for every $$$1 \le i \lt n$$$.

Cirno does not want to deal with large numbers, so for each test case she only wants to know the answer modulo $$$2$$$.

$$$^{\text{∗}}$$$$$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$.

Input

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.

Each of the next $$$t$$$ lines contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 5 \cdot 10^4$$$).

Output

For each test case, output a single integer — the required count modulo $$$2$$$.

Example
Input
5
2 5
2 6
2 7
40000 50000
30001 50000
Output
1
1
1
0
1
Note

In the first test case ($$$n = 2$$$, $$$m = 5$$$), the valid arrays $$$b$$$ are $$$[1,2]$$$, $$$[1,3]$$$, $$$[1,4]$$$, $$$[1,5]$$$, $$$[2,3]$$$, $$$[2,5]$$$, $$$[3,4]$$$, $$$[3,5]$$$, $$$[4,5]$$$. There are $$$9$$$ of them, so the answer is $$$9 \bmod 2 = 1$$$.

In the second test case ($$$n = 2$$$, $$$m = 6$$$), the nine arrays listed above are valid, and so are $$$[1,6]$$$ and $$$[5,6]$$$. There are $$$11$$$ of them, so the answer is $$$1$$$.

In the third test case ($$$n = 2$$$, $$$m = 7$$$), the eleven arrays listed above are valid, and so are $$$[1,7]$$$, $$$[2,7]$$$, $$$[3,7]$$$, $$$[4,7]$$$, $$$[5,7]$$$, and $$$[6,7]$$$. There are $$$17$$$ of them, so the answer is $$$1$$$.