Hide

Problem B
Miller-Rabin Witness

Languages en is

Determine if an integer a is a Miller-Rabin witness for an integer n.

Input

The first line contains a number 1t105, the number of test cases.

Each test case consists of two lines. First line consist of an integer 3n2631. The second line consists of an integer 1amin{n1,2311}.

Output

For each test case, write a single line with 1 if a is a Miller-Rabin witness for n, or 0 otherwise.

Sample Input 1 Sample Output 1
2
561
2
172947527
17
1
0
Hide

Please log in to submit a solution to this problem

Log in