You are given an integer sequence
of length and an integer such that .
An integer sequence of length is called good if:
- for each
Find the maximum value of over all good sequences . Here, denotes the greatest common divisor.
Note: and .
Input Format
- The first line of input contains a single integer , denoting the number of test cases. The description of test cases follows.
- The first line of each test case contains two space-separated integers .
- The second line of each test case contains space-separated integers .
Output Format
For each test case, print a single line containing one integer — the maximum value of over all good sequences .
Constraints
Subtasks
Subtask #1 (50 points):
Subtask #2 (50 points): Original constraints
Sample Input 1
4
4 4
1 3 5 7
4 4
5 5 5 5
4 0
4 6 9 12
6 10
15 9 3 8 14 17
Sample Output 1
3
4
1
7
Explanation
Test case : The optimal strategy is to take . The answer is .
Test case : The optimal strategy is to take . The answer is .
ConversionConversion EmoticonEmoticon