#414. Pass!

Pass!

Description

There are nn players passing ball on the football field.

Initially, the first player has the ball. Then each second, the player with ball should pass the ball to any other player.

Alice wonders how many way to pass the ball, such that after t seconds, the ball will turn back to the first player. So she asks Bob for help.

Now, Bob solved the question and found that the answer modulo 998244353998244353 is xx. But he forgot the exact number of t. So he ask you for help, to find the smallest non-negative integer tt, such that the answer of Alice's question modulo 998244353998244353 will be xx.

Format

Input

The first line contains an integer T(1T100)T(1≤T≤100)representing the number of test cases.

For each test case, there are two integers n,x(2n106,0x<998244353)n,x(2≤n≤10^6,0≤x<998244353)in one line.

Output

For each test case, output a single line containing one integer indicates the smallest tt. If such t do not exist, output 1−1 instead.

Samples

5
11 1
11 0
11 10
11 76805204
11 2
0
1
2
233333
-1