Greedy#3717

Greedy

2 seconds
64 megabytes
Medium

Two players are engaged in a game called "Greedy". They start with a pile of candies, and take turns removing between and candies from the pile. The player who takes the last candy loses the game. Your task is to determine how many candies the first player should take on their first turn to ensure a win, assuming both players make optimal moves.

Input

The first line contains the number of games (1 \leq t \leq 10^5). Each of the following lines provides the details for a game with two integers: (1 \leq n \leq 10^9) and (1 \leq k \leq 10^9).

Output

For each game, output the number of candies the first player should take to guarantee a win. If the first player is destined to lose regardless of their strategy, output . If there are multiple valid answers, you may output any one of them.

Examples

Example 1

Loading
Loading