You are given two arrays a1,a2,…,an and b1,b2,…,bn . You must perform the following…
- User
You are given two arrays a1,a2,…,an and b1,b2,…,bn .
You must perform the following operation exactly once:
choose any indices l and r such that 1≤l≤r≤n ; swap ai and bi for all i such that l≤i≤r . Find the maximum possible value of gcd(a1,a2,…,an)+gcd(b1,b2,…,bn) after performing the operation exactly once. Also find the number of distinct pairs (l,r) which achieve the maximum value.
Input In the first line of the input, you are given a single integer t (1≤t≤105 ), the number of test cases. Then the description of each test case follows.
In the first line of each test case, you are given a single integer n (1≤n≤2⋅105 ), representing the number of integers in each array.
In the next line, you are given n integers a1,a2,…,an (1≤ai≤109 ) — the elements of the array a .
In the last line, you are given n integers b1,b2,…,bn (1≤bi≤109 ) — the elements of the array b .
The sum of values of n over all test cases does not exceed 5⋅105 .
Output For each test case, output a line with two integers: the maximum value of gcd(a1,a2,…,an)+gcd(b1,b2,…,bn) after performing the operation exactly once, and the number of ways.
- Assistant