#P1944A. Destroying Bridges

Destroying Bridges

No submission language available for this problem.

Description

There are nn islands, numbered 1,2,,n1, 2, \ldots, n. Initially, every pair of islands is connected by a bridge. Hence, there are a total of n(n1)2\frac{n (n - 1)}{2} bridges.

Everule lives on island 11 and enjoys visiting the other islands using bridges. Dominater has the power to destroy at most kk bridges to minimize the number of islands that Everule can reach using (possibly multiple) bridges.

Find the minimum number of islands (including island 11) that Everule can visit if Dominater destroys bridges optimally.

Each test contains multiple test cases. The first line contains a single integer tt (1t1031 \leq t \leq 10^3) — the number of test cases. The description of the test cases follows.

The first and only line of each test case contains two integers nn and kk (1n1001 \le n \le 100, 0kn(n1)20 \le k \le \frac{n \cdot (n - 1)}{2}).

For each test case, output the minimum number of islands that Everule can visit if Dominater destroys bridges optimally.

Input

Each test contains multiple test cases. The first line contains a single integer tt (1t1031 \leq t \leq 10^3) — the number of test cases. The description of the test cases follows.

The first and only line of each test case contains two integers nn and kk (1n1001 \le n \le 100, 0kn(n1)20 \le k \le \frac{n \cdot (n - 1)}{2}).

Output

For each test case, output the minimum number of islands that Everule can visit if Dominater destroys bridges optimally.

Sample Input 1

6
2 0
2 1
4 1
5 10
5 3
4 4

Sample Output 1

2
1
4
1
5
1

Note

In the first test case, since no bridges can be destroyed, all the islands will be reachable.

In the second test case, you can destroy the bridge between islands 11 and 22. Everule will not be able to visit island 22 but can still visit island 11. Therefore, the total number of islands that Everule can visit is 11.

In the third test case, Everule always has a way of reaching all islands despite what Dominater does. For example, if Dominater destroyed the bridge between islands 11 and 22, Everule can still visit island 22 by traveling by 1321 \to 3 \to 2 as the bridges between 11 and 33, and between 33 and 22 are not destroyed.

In the fourth test case, you can destroy all bridges since k=n(n1)2k = \frac{n \cdot (n - 1)}{2}. Everule will be only able to visit 11 island (island 11).