Stifling the Mutiny#3113

Stifling the Mutiny

1 second
128 megabytes
Medium

A group of pirates is escorting a convoy of ships sailing in a row. However, the pirate captain is losing control over the crew, and some disloyal pirates are ready to start a mutiny. On any ship , if the number of loyal pirates on is less than the total number of disloyal pirates on , the previous ship (if is not the first), and the next ship (if is not the last), then the disloyal pirates from these ships will move to to seize it.

To prevent a mutiny, the captain wants to distribute loyal and disloyal pirates among the ships so that disloyal pirates cannot seize any ship. Each ship must have at least one loyal pirate to operate it.

Input

The first line contains the number of test cases.

Each test is one line that contains two integers and (1 \leq n \leq 15, n \leq k \leq 40). The first integer is the number of ships; the second integer is the total number of pirates (loyal and disloyal) in the convoy.

Output

For each test case, print on a single line the maximum number of disloyal pirates the captain can distribute among the ships such that the disloyal pirates cannot seize any ship.

Examples

Example 1

Loading
Loading