Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

C. Physical Education Lesson
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

In a well-known school, a physical education lesson took place. As usual, everyone was lined up and asked to settle in "the first–k-th" position.

As is known, settling in "the first–k-th" position occurs as follows: the first k people have numbers 1,2,3,,k, the next k2 people have numbers k1,k2,,2, the next k people have numbers 1,2,3,,k, and so on. Thus, the settling repeats every 2k2 positions. Examples of settling are given in the "Note" section.

The boy Vasya constantly forgets everything. For example, he forgot the number k described above. But he remembers the position he occupied in the line, as well as the number he received during the settling. Help Vasya understand how many natural numbers k fit under the given constraints.

Note that the settling exists if and only if k>1. In particular, this means that the settling does not exist for k=1.

Input

Each test consists of multiple test cases. The first line contains a single integer t (1t100) — the number of test cases. This is followed by the description of the test cases.

The only line of each test case contains two integers n and x (1x<n109) — Vasya's position in the line and the number Vasya received during the settling.

Output

For each test case, output a single integer — the number of different k that fit under the given constraints.

It can be proven that under the given constraints, the answer is finite.

Example
Input
5
10 2
3 1
76 4
100 99
1000000000 500000000
Output
4
1
9
0
1
Note

In the first test case, k equals 2,3,5,6 are suitable.

An example of settling for these k:

k / №12345678910
21212121212
31232123212
51234543212
61234565432

In the second test case, k=2 is suitable.