**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
#include<bits/stdc++.h>
#define L(i, l, r) for(int i = l; i <= r; i ++)
#define R(i, l, r) for(int i = l; i >= r; i --)
#define fi first
#define se second
#define ll long long
#define ld long double
#define vi vector <int>
#define vl vector <long long>
#define sz(a) ((int) (a).size())
#define me(f, x) memset(f, x, sizeof(f))
#define ull unsigned long long
using namespace std;
struct ST {
    const int n, k;
    vector<int> in;
    vector<vector<int>> rmq;
    ST(int n, vector<int> &v) : n(n), in(n + 1), k(__lg(n)) {
        rmq.resize(k + 1, vector<int>(n + 1));
        in = v;
    }
    void init() {
        for (int i = 1; i <= n; i++) {
            rmq[0][i] = in[i];
        }
        for (int i = 0, t = 1; i < k; i++, t <<= 1) {
            const int T = n - (t << 1) + 1;
            for (int j = 1; j <= T; j++) {
                rmq[i + 1][j] = gcd(rmq[i][j], rmq[i][j + t]);
            }
        }
    }
    int getGcd(int l, int r) {
        if (l > r) {
            swap(l, r);
        }
        int k = __lg(r - l + 1);
        return gcd(rmq[k][l], rmq[k][r - (1 << k) + 1]);
    }
};

void solve(){
    int n; cin >> n;
    vector <int> a(n + 1, 0), b(n + 1, 0);
    L(i, 1, n) cin >> a[i];
    L(i, 1, n) cin >> b[i];

    ST A(n, a); A.init();
    ST B(n, b); B.init();

    set <int> t;
    map <int, int> mp;

    for(int i = n - 1; i >= 0; i --){
        if(i == 0 || A.getGcd(n, i) != A.getGcd(n, i + 1)|| B.getGcd(n, i) != B.getGcd(n, i + 1)){
           t.insert(i + 1);
        }
    }

    set <int> v;
    auto cal = [&] (int i) -> void {
        v = t;
        for(int j = i; j <= n; ){
            int lo = j, hi = n, d = A.getGcd(i, j);
            while(lo < hi){
                int mid = lo + hi >> 1;
                if(A.getGcd(j, mid) <= d) hi = mid;
                else lo = mid + 1;
            }
            v.insert(lo);
            j = lo + 1;
        }
        for(int j = i; j <= n; ){
            int lo = j, hi = n, d = B.getGcd(i, j);
            while(lo < hi){
                int mid = lo + hi >> 1;
                if(B.getGcd(j, mid) <= d) hi = mid;
                else lo = mid + 1;
            }
            v.insert(lo);
            j = lo + 1;
        }
    };

    int mx = 0;
    for(int i = 1; i <= n; i ++){
        int dla = (i == 1) ? 0 : A.getGcd(1, i - 1);
        int dlb = (i == 1) ? 0 : B.getGcd(1, i - 1);

        cal(i);

        int cur = i;
        for(auto &r : v){
            int d1  = A.getGcd(i, r), d2 = B.getGcd(i, r);
            int dra = 0, drb = 0;
            if(r != n){
                dra = A.getGcd(r + 1, n);
                drb = B.getGcd(r + 1, n);
            }
            int da  = __gcd(dla, dra), db = __gcd(dlb, drb);
            int ans = __gcd(da, d2) +  __gcd(db, d1), c = (r - cur + 1);
            cur = r + 1, mp[ans] += c;
            mx  = max(mx, ans);
            // if(ans > mx){
            //    cout << ans << endl;
            //    cout << i << " " << cur << " " << r << endl;
            //    mx = ans;
            // }
        }
        t.erase(i);
    }
    cout << mx << " " << mp[mx] << endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int Case; cin >> Case; while(Case --) solve();

    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4
1 2 3 4
4 3 2 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
import sys
import math
from collections import defaultdict

input = sys.stdin.read

def compute_gcd(x, y):
    """Compute the GCD of two numbers."""
    return math.gcd(x, y)

def precompute_gcds(arr):
    """Precompute GCDs for all subarrays of a given array."""
    n = len(arr)
    gcd_table = [[0] * n for _ in range(n)]
    for i in range(n):
        gcd_table[i][i] = arr[i]
        for j in range(i + 1, n):
            gcd_table[i][j] = compute_gcd(gcd_table[i][j - 1], arr[j])
    return gcd_table

def find_max_gcd_sum_and_count(n, a, b):
    """Find the maximum GCD sum and the number of ways to achieve it."""
    gcd_a = precompute_gcds(a)
    gcd_b = precompute_gcds(b)

    max_gcd_sum = 0
    count = 0

    for l in range(n):
        for r in range(l, n):
            new_a = a[:l] + b[l:r+1] + a[r+1:]
            new_b = b[:l] + a[l:r+1] + b[r+1:]

            gcd_a_new = compute_gcd(new_a[0], new_a[1])
            for i in range(2, n):
                gcd_a_new = compute_gcd(gcd_a_new, new_a[i])

            gcd_b_new = compute_gcd(new_b[0], new_b[1])
            for i in range(2, n):
                gcd_b_new = compute_gcd(gcd_b_new, new_b[i])

            current_sum = gcd_a_new + gcd_b_new

            if current_sum > max_gcd_sum:
                max_gcd_sum = current_sum
                count = 1
            elif current_sum == max_gcd_sum:
                count += 1

    return max_gcd_sum, count

def process_test_cases():
    """Process all test cases and output results."""
    data = input().split()
    idx = 0
    t = int(data[idx])
    idx += 1

    results = []

    for _ in range(t):
        n = int(data[idx])
        idx += 1
        a = list(map(int, data[idx:idx + n]))
        idx += n
        b = list(map(int, data[idx:idx + n]))
        idx += n

        max_sum, count = find_max_gcd_sum_and_count(n, a, b)
        results.append(f"{max_sum} {count}")

    print("\n".join(results))

if __name__ == "__main__":
    process_test_cases()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To create a challenging test input that exposes the bug in the provided buggy code, we need to focus on scenarios where the precomputed GCDs might not be correctly utilized, or where the swapping operation might lead to unexpected results. Here are the steps to think through this:

1. **Edge Cases**:
   - Arrays with all elements being the same.
   - Arrays with elements that have a common factor.
   - Arrays with elements that are prime numbers.
   - Arrays with elements that are multiples of each other.

2. **Scenarios to Maximize Failure**:
   - Test cases where the GCD of the entire array is 1, and any swap should not change this.
   - Test cases where the GCD of the entire array is greater than 1, and a specific swap can maximize the GCD sum.
   - Test cases with a small number of elements to ensure the test is small-scale.

3. **Constructing the Test Input**:
   - We will create a test case with `n = 4` to keep it small.
   - We will use elements that have a common factor to ensure that the GCD is not always 1.
   - We will ensure that the swap can potentially change the GCD sum.

Here is the test input:

```plaintext
1
4
6 4 24 13
15 3 1 14
```

Explanation:
- `n = 4`
- `a = [6, 4, 24, 13]`
- `b = [15, 3, 1, 14]`

In this test case:
- The GCD of the entire array `a` is 1.
- The GCD of the entire array `b` is 1.
- Swapping elements in certain ranges might not change the GCD, but we need to ensure that the code correctly handles the precomputed GCDs and the swapping logic.

This test case should help expose any issues with the precomputed GCDs and the logic for finding the maximum GCD sum and the number of ways to achieve it.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
import math
from itertools import combinations

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def max_gcd_and_count(n, a, b):
    max_sum = 0
    count = 0

    # Iterate over all possible subarrays
    for l in range(n):
        for r in range(l, n):
            # Swap elements in the subarray [l, r]
            a_sub, b_sub = a[:], b[:]
            for i in range(l, r + 1):
                a_sub[i], b_sub[i] = b_sub[i], a_sub[i]

            # Calculate the GCDs of the modified arrays
            gcd_a = a_sub[0]
            for i in range(1, n):
                gcd_a = gcd(gcd_a, a_sub[i])

            gcd_b = b_sub[0]
            for i in range(1, n):
                gcd_b = gcd(gcd_b, b_sub[i])

            # Update the maximum sum and count
            if gcd_a + gcd_b > max_sum:
                max_sum = gcd_a + gcd_b
                count = 1
            elif gcd_a + gcd_b == max_sum:
                count += 1

    return max_sum, count

# Main function to handle input/output
def main():
    import sys
    input = sys.stdin.read
    data = input().split()

    index = 0
    t = int(data[index])
    index += 1
    results = []

    for _ in range(t):
        n = int(data[index])
        index += 1
        a = list(map(int, data[index:index + n]))
        index += n
        b = list(map(int, data[index:index + n]))
        index += n

        max_sum, count = max_gcd_and_count(n, a, b)
        results.append((max_sum, count))

    for res in results:
        print(*res)

if __name__ == "__main__":
    main()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To create a challenging test input that exposes the bug in the provided code, we need to focus on edge cases or scenarios that maximize the failure probability in faulty solutions. Here are the steps to consider:

1. **Arrays with identical elements**: If both arrays have identical elements, the GCD of each array will be the element itself, and swapping any subarray will not change the GCD.
2. **Arrays with coprime elements**: If the elements in the arrays are coprime, the GCD of the arrays will be 1, and swapping any subarray will not change the GCD.
3. **Arrays with a mix of elements**: If the arrays have a mix of elements, some of which are coprime and some of which have common factors, the GCD can change significantly depending on the swap.
4. **Small arrays**: Small arrays are easier to manage and test, and they can help in quickly verifying the correctness of the solution.

Given these considerations, let's create a small-scale test input that includes a mix of elements and is likely to expose the bug in the code.

```plaintext
5
4
2 3 4 5
6 7 8 9
2
1 1
1 1
3
1 2 3
2 3 4
4
10 20 30 40
5 10 15 20
2
12 15
18 21
```

Explanation:
1. **Test Case 1**: Arrays `[2, 3, 4, 5]` and `[6, 7, 8, 9]` have no common factors other than 1, so the GCD of each array is 1. Swapping any subarray will not change the GCD.
2. **Test Case 2**: Arrays `[1, 1]` and `[1, 1]` have identical elements, so the GCD of each array is 1. Swapping any subarray will not change the GCD.
3. **Test Case 3**: Arrays `[1, 2, 3]` and `[2, 3, 4]` have elements that are not all coprime, but the GCD of each array is 1. Swapping any subarray will not change the GCD.
4. **Test Case 4**: Arrays `[10, 20, 30, 40]` and `[5, 10, 15, 20]` have elements with common factors, so the GCD of each array is 10 and 5 respectively. Swapping the entire array will change the GCD to 10 + 5 = 15.
5. **Test Case 5**: Arrays `[12, 15]` and `[18, 21]` have elements with common factors, so the GCD of each array is 3 and 3 respectively. Swapping the entire array will change the GCD to 3 + 3 = 6.

This test input is designed to cover a range of scenarios that can help identify the bug in the provided code.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
import sys
import math
from typing import List

def main():
    import sys
    sys.setrecursionlimit(1 << 25)
    T = int(input())
    for _ in range(T):
        N = int(sys.stdin.readline())
        a = list(map(int, sys.stdin.readline().split()))
        b = list(map(int, sys.stdin.readline().split()))

        # Precompute prefix and suffix GCDs for a and b
        prefix_gcd_a = [0] * (N + 2)
        suffix_gcd_a = [0] * (N + 2)
        prefix_gcd_b = [0] * (N + 2)
        suffix_gcd_b = [0] * (N + 2)

        for i in range(1, N + 1):
            prefix_gcd_a[i] = math.gcd(prefix_gcd_a[i - 1], a[i - 1])
            prefix_gcd_b[i] = math.gcd(prefix_gcd_b[i - 1], b[i - 1])

        for i in range(N, 0, -1):
            suffix_gcd_a[i] = math.gcd(suffix_gcd_a[i + 1], a[i - 1])
            suffix_gcd_b[i] = math.gcd(suffix_gcd_b[i + 1], b[i - 1])

        # Build sparse tables for range GCD queries
        MAX_LOG = 18  # Since 2^18 > 2*10^5
        sparse_table_a = [[0 for _ in range(MAX_LOG)] for _ in range(N + 1)]
        sparse_table_b = [[0 for _ in range(MAX_LOG)] for _ in range(N + 1)]

        for i in range(1, N + 1):
            sparse_table_a[i][0] = a[i - 1]
            sparse_table_b[i][0] = b[i - 1]

        for j in range(1, MAX_LOG):
            for i in range(1, N - (1 << j) + 2):
                sparse_table_a[i][j] = math.gcd(sparse_table_a[i][j - 1], sparse_table_a[i + (1 << (j - 1))][j - 1])
                sparse_table_b[i][j] = math.gcd(sparse_table_b[i][j - 1], sparse_table_b[i + (1 << (j - 1))][j - 1])

        def query(table, L, R):
            k = 0
            while (1 << (k + 1)) <= R - L + 1:
                k += 1
            return math.gcd(table[L][k], table[R - (1 << k) + 1][k])

        max_sum = 0
        count = 0
        for L in range(1, N + 1):
            for R in range(L, N + 1):
                gcd_a_new = math.gcd(math.gcd(prefix_gcd_a[L - 1], query(sparse_table_b, L, R)), suffix_gcd_a[R + 1])
                gcd_b_new = math.gcd(math.gcd(prefix_gcd_b[L - 1], query(sparse_table_a, L, R)), suffix_gcd_b[R + 1])
                current_sum = gcd_a_new + gcd_b_new
                if current_sum > max_sum:
                    max_sum = current_sum
                    count = 1
                elif current_sum == max_sum:
                    count += 1
        print(max_sum, count)

if __name__ == "__main__":
    main()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
1
10
5
2
10 15
5 20
4
2 4 6 8
3 6 9 12
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
import java.util.*;
import java.io.*;

public class Main {
    private static BufferedReader br;
    private static StringTokenizer tokenizer;
    private static String next() throws IOException{
        if (br == null) br = new BufferedReader(new InputStreamReader(System.in));
        if (tokenizer == null) tokenizer = new StringTokenizer(br.readLine());
        while (!tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(br.readLine());
        return tokenizer.nextToken();
    }
    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException{
        return Long.parseLong(next());
    }

    private static StringBuilder sb = new StringBuilder();

    static int MAX_VALUE = 500_001;
    static int[] a = new int[MAX_VALUE];
    static int[] b = new int[MAX_VALUE];
    static int[][] st1 = new int[MAX_VALUE][32];
    static int[][] st2 = new int[MAX_VALUE][32];
    static int n;
    static int len;

    static int[] suffixA = new int[MAX_VALUE + 1];
    static int[] suffixB = new int[MAX_VALUE + 1];
    static int[] prefixA = new int[MAX_VALUE + 1];
    static int[] prefixB = new int[MAX_VALUE + 1];
    static List<Integer> suffixChanges = new ArrayList<>(64);

    static int gcd(int x, int y) {
        if (x > y) {
            int t = x;
            x = y;
            y = t;
        }
        if (x == 0) return y;
        if (y % x == 0) return x;
        return gcd(y % x, x);
    }

    static void build(int[] arr, int[][] st) {
        for (int i = 0; i < n; ++i) st[i][0] = arr[i];
        for (int i = 0; i < n; ++i) {
            for (int j = 1; j < len; ++j) st[i][j] = gcd(st[Math.max(i - (1 << (j - 1)), 0)][j - 1],st[i][j - 1]);
        }
    }

    static int qSt(int[][] st, int l, int r) {
        if (l > r || l >= n) return 0;
        int i = 0;
        while ((1 << i) <= (r - l + 1)) ++i;
        --i;
        int ans = 0;
        int cnt = 0;
        while (l <= r) {
            assert i >= 0;
            ++cnt;
            assert cnt < 100;
            ans = gcd(ans, st[r][i]);
            r -= (1 << i);
            while ((1 << i) > (r - l + 1)) --i;
        }
        return ans;
    }

    static int qBound(int[][] st, int p, int v, boolean op) {
        int l = op ? p : -1;
        int r = op ? n : p;
        int i = 0;
        while ((1 << i) <= (r - l)) ++i;
        --i;
        int cnt = 0;
        while (l < r) {
            ++cnt;
            assert cnt < 100;
            assert i >= 0;
            int g = gcd(v, st[op ? (l + (1 << i) - 1) : r][i]);
            if (g == v) {
                if (op) {
                    l += (1 << i);
                } else {
                    r -= (1 << i);
                }
            } else {
                if (op) {
                    r = l + (1 << i) - 1;
                } else {
                    l = r - (1 << i) + 1;
                }
            }

            while ((1 << i) > (r - l)) --i;
        }
        return l;
    }

    private static void slove() throws IOException{
        n = nextInt();
        len = 0;
        while ((1 << len) <= n) ++len;
        ++len;
        for (int i = 0; i < n; ++i) a[i] = nextInt();
        for (int i = 0; i < n; ++i) b[i] = nextInt();
        build(a, st1);
        build(b, st2);

        suffixA[n] = suffixB[n] = 0;
        for (int i = n - 1; i >= 0; --i) {
            suffixA[i] = gcd(suffixA[i + 1], a[i]);
            suffixB[i] = gcd(suffixB[i + 1], b[i]);
        }
        suffixChanges.clear();
        suffixChanges.add(n);
        for (int i = n - 1; i >= 0; --i) {
            if (suffixA[i] != suffixA[i + 1] || suffixB[i] != suffixB[i + 1]) suffixChanges.add(i);
        }
        prefixA[0] = a[0];
        prefixB[0] = b[0];
        for (int i = 1; i < n; ++i) {
            prefixA[i] = gcd(prefixA[i - 1], a[i]);
            prefixB[i] = gcd(prefixB[i - 1], b[i]);
        }

        long v = 0, cnt = 0;
        for (int i = 0; i < n; ++i) {
            int la = i == 0 ? 0 : prefixA[i - 1], lb = i == 0 ? 0 : prefixB[i - 1];

            int index = suffixChanges.size() - 1;
            int midGA = 0, midGB = 0;
            for (int j = i; j < n;) {
                midGA = gcd(midGA, a[j]);
                midGB = gcd(midGB, b[j]);
                while (suffixChanges.get(index) <= j) --index;
                int ka = qBound(st1, j, midGA, true), kb = qBound(st2, j, midGB, true);
                int k = Math.min(Math.min(ka, kb) - 1, suffixChanges.get(index));
                int curV = gcd(gcd(la, midGB), suffixA[suffixChanges.get(index)]) + gcd(gcd(lb, midGA), suffixB[suffixChanges.get(index)]);
                if (curV > v) {
                    v = curV;
                    cnt = 0;
                }
                if (curV >= v) {
                    cnt += k - j + 1;
                }
                j = k + 1;
            }
        }

        test += 2;
        if (test >= 115250 && test <= 115255) {
            StringBuilder outSb = new StringBuilder();
            for (int i = 0; i < n; ++i) outSb.append(a[i]).append(" ");
            outSb.append("----");
            for (int i = 0; i < n; ++i) outSb.append(b[i]).append(" ");
            System.out.println(outSb);
        }

        sb.append(v).append(" ").append(cnt).append("\n");
    }

    static int line = 0;
    static int test = 0;

    public static void main(String[] args)  throws IOException {
        int tt = nextInt();
        sb = new StringBuilder();
//        long sumTime = 0L;
        for (int i = 0; i < tt; ++i) {
            ++line;
//            long startTime = System.currentTimeMillis();
            slove();
//            sumTime += System.currentTimeMillis() - startTime;
        }
        System.out.println(sb);
//        System.out.println(sumTime / tt);
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
import java.util.*;
import java.io.*;

public class Main {
    private static BufferedReader br;
    private static StringTokenizer tokenizer;
    private static String next() throws IOException{
        if (br == null) br = new BufferedReader(new InputStreamReader(System.in));
        if (tokenizer == null) tokenizer = new StringTokenizer(br.readLine());
        while (!tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(br.readLine());
        return tokenizer.nextToken();
    }
    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException{
        return Long.parseLong(next());
    }

    private static StringBuilder sb = new StringBuilder();

    static int MAX_VALUE = 500_001;
    static int[] a = new int[MAX_VALUE];
    static int[] b = new int[MAX_VALUE];
    static int[][] st1 = new int[MAX_VALUE][32];
    static int[][] st2 = new int[MAX_VALUE][32];
    static int n;
    static int len;

    static int gcd(int x, int y) {
        if (x > y) {
            int t = x;
            x = y;
            y = t;
        }
        if (x == 0) return y;
        if (y % x == 0) return x;
        return gcd(y % x, x);
    }

    static void build(int[] arr, int[][] st) {
        for (int i = 0; i < n; ++i) st[i][0] = arr[i];
        for (int i = 0; i < n; ++i) {
            for (int j = 1; j < len; ++j) st[i][j] = gcd(st[Math.max(i - (1 << (j - 1)), 0)][j - 1],st[i][j - 1]);
        }
    }

    static int qSt(int[][] st, int l, int r) {
        if (l > r || l >= n) return 0;
        int i = 0;
        while ((1 << i) <= (r - l + 1)) ++i;
        --i;
        int ans = 0;
        while (l <= r) {
            ans = gcd(ans, st[r][i]);
            r -= (1 << i);
            while ((1 << i) > (r - l + 1)) --i;
        }
        return ans;
    }

    static int qBound(int[][] st, int p, int v, boolean op) {
        int l = op ? p : -1;
        int r = op ? n : p;
        int i = 0;
        while ((1 << i) <= (r - l)) ++i;
        --i;
        while (l < r) {
            int g = gcd(v, st[op ? (l + (1 << i)) : r][i]);
            if (g == v) {
                if (op) {
                    l += (1 << i);
                } else {
                    r -= (1 << i);
                }
            } else {
                if (op) {
                    r = l + (1 << i) - 1;
                } else {
                    l = r - (1 << i) + 1;
                }
            }

            while ((1 << i) > (r - l)) --i;
        }
        return l;
    }

    private static void slove() throws IOException{
        n = nextInt();
        len = 0;
        while ((1 << len) <= n) ++len;
        ++len;
        for (int i = 0; i < n; ++i) a[i] = nextInt();
        for (int i = 0; i < n; ++i) b[i] = nextInt();
        build(a, st1);
        build(b, st2);

        if (curTT >= 495 && curTT <= 500) System.out.println(Arrays.toString(a) + "-----" + Arrays.toString(b));

        int v = 0, cnt = 0;
        for (int r = 0; r < n; ++r) {
            int ga = a[r], gb = b[r];
            int rga = qSt(st1, r + 1, n - 1), rgb = qSt(st2, r + 1, n - 1);
            int ll = r;
            while (ll >= 0) {
                ga = gcd(ga, a[ll]);
                gb = gcd(gb, b[ll]);
                int rrA = qBound(st1, ll, ga, false), rrB = qBound(st2, ll, gb, false);
                int rr = Math.max(rrA, rrB);
                int curA = gcd(gcd(qSt(st1, 0, rr), qSt(st2, rr + 1, r)), rga), curB = gcd(gcd(qSt(st2, 0, rr), qSt(st1, rr + 1, r)), rgb);
                int curV = curA + curB;
                if (curV >= v) {
                    if (curV > v) {
                        v = curV;
                        cnt = 0;
                    }
                    int rightA = qBound(st1, rr + 1, curA, true), rightB = qBound(st2, rr + 1, curB, true);
                    int right = Math.min(Math.min(rightA, rightB), ll);
                    cnt += right - rr;
                }
                ll = rr;
            }
        }
        sb.append(v).append(" ").append(cnt).append("\n");
    }

    static int curTT;

    public static void main(String[] args)  throws IOException {
        int tt = nextInt();
        sb = new StringBuilder();
//        long sumTime = 0L;
        for (int i = 0; i < tt; ++i) {
            curTT = i;
//            long startTime = System.currentTimeMillis();
            slove();
//            sumTime += System.currentTimeMillis() - startTime;
        }
        System.out.println(sb);
//        System.out.println(sumTime / tt);
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5
1 2 3 4 5
5 4 3 2 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
#include<bits/stdc++.h>
using namespace std;

int findGCD(vector<int>& arr) {
    int result = arr[0];
    for (int i = 1; i < arr.size(); i++) {
        result = gcd(result, arr[i]);
    }
    return result;
}

pair<int, int> solve(vector<int>& a, vector<int>& b) {
    int maxGCD = 0;
    int count = 0;

    for (int l = 0; l < a.size(); l++) {
        for (int r = l; r < a.size(); r++) {
            vector<int> newA = a;
            vector<int> newB = b;
            for (int i = l; i <= r; i++) {
                swap(newA[i], newB[i]);
            }
            int newGCD = findGCD(newA) + findGCD(newB);
            if (newGCD > maxGCD) {
                maxGCD = newGCD;
                count = 1;
            } else if (newGCD == maxGCD) {
                count++;
            }
        }
    }

    return make_pair(maxGCD, count);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        int n;
        cin >> n;
        vector<int> a(n);
        vector<int> b(n);
        for (int j = 0; j < n; j++) cin >> a[j];
        for (int j = 0; j < n; j++) cin >> b[j];
        pair<int, int> result = solve(a, b);
        cout << result.first << " " << result.second << endl;
    }

	return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
5
1 2 3 4 5
6 7 8 9 10
4
2 4 6 8
1 3 5 7
2
1 1
1 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
#include<bits/stdc++.h>
#define inf 0X7fffffff
#define int long long
using namespace std;
const int N=2e5+9;
int read(int &x){
    int dat=0,oko=1;char chc=getchar();
    while(chc<'0'||chc>'9'){if(chc=='-')oko=-1;chc=getchar();}
    while(chc>='0'&&chc<='9'){dat=dat*10+chc-'0';chc=getchar();}
    x=dat*oko;return x;
}int T,n,agcdl[N],agcdr[N],bgcdl[N],bgcdr[N];
int treea[N<<1],treeb[N<<1],num,ans,a[N],b[N];
int gcd(int x,int y){
    while(y){
        x=x%y;swap(x,y);
    }return x;
}void updata(int num){
    treea[num]=gcd(treea[num<<1],treea[num<<1|1]);
    treeb[num]=gcd(treeb[num<<1],treeb[num<<1|1]);
}
void build(int l,int r,int num){
    if(l==r){
        treea[num]=a[l];
        treeb[num]=b[l];
    //    printf("%d to %d gcd=%d and %d\n",l,r,treea[num],treeb[num]);
        return;
    }int mid=(l+r)>>1;
    build(l,mid,num<<1);
    build(mid+1,r,num<<1|1);
    updata(num);
    //printf("%d to %d gcd=%d and %d\n",l,r,treea[num],treeb[num]);
}int querya(int l,int r,int num,int ll,int rr){
    //printf("qeury %d %d %d \n",l,r,treea[num]);
    if(ll>r||rr<l)return 0;
    if(ll<=l&r<=rr){return treea[num];}
    int mid=(l+r)>>1,g1=0,g2=0;
    if(mid>=ll)g1=querya(l,mid,num<<1,ll,rr);
    if(mid+1<=rr)g2=querya(mid+1,r,num<<1|1,ll,rr);
    if(g1&&g2)return gcd(g1,g2);
    if(g1)return g1;
    if(g2)return g2;
}int queryb(int l,int r,int num,int ll,int rr){
    if(ll>r||rr<l)return 0;
    if(ll<=l&r<=rr){return treeb[num];}
    int mid=(l+r)>>1,g1=0,g2=0;
    if(mid>=ll)g1=queryb(l,mid,num<<1,ll,rr);
    if(mid+1<=rr)g2=queryb(mid+1,r,num<<1|1,ll,rr);
    //printf("%d to %d g1=%d g2=%d\n",l,r,g1,g2);
    if(g1&&g2)return gcd(g1,g2);
    if(g1)return g1;
    if(g2)return g2;
}int solve(int l,int r){
    int ga=queryb(1,n,1,l,r);
    int gb=querya(1,n,1,l,r);
    //printf("gcd %d to %d =%d and %d\n",l,r,gb,ga);
    if(l>1){
        ga=gcd(ga,agcdl[l-1]);
        gb=gcd(gb,bgcdl[l-1]);
    }if(r<n){
        ga=gcd(ga,agcdr[r+1]);
        gb=gcd(gb,bgcdr[r+1]);
    }
    return ga+gb;
}
signed main(){
    ios::sync_with_stdio(false);
    cin>>T;
    while(T--){
        cin>>n;ans=0,num=0;
        for(int i=1;i<=n;i++)cin>>a[i];
        for(int i=1;i<=n;i++)cin>>b[i];
        agcdl[1]=a[1];bgcdl[1]=b[1];
        for(int i=2;i<=n;i++){
            agcdl[i]=gcd(agcdl[i-1],a[i]);
            bgcdl[i]=gcd(bgcdl[i-1],b[i]);
        }agcdr[n]=a[n];bgcdr[n]=b[n];
        for(int i=n-1;i>=1;i--){
            agcdr[i]=gcd(agcdr[i+1],a[i]);
            bgcdr[i]=gcd(bgcdr[i+1],b[i]);
        }build(1,n,1);
        //printf("fkpps %d %d\n",querya(1,n,1,2,2),queryb(1,n,1,2,2));
        for(int l=1;l<=n;l++){
            //if(l>1&&agcdl[l-1]<ans&&ans)break;
            //if(l>1&&bgcdl[l-1]<ans&&ans)break;
//            int L=l,r=n;
//            int mx=0,pos=0;
//            while(l<=r){
//                int midl=l+(r-l)/3;
//                int midr=r-(r-l)/3;
//                if(midr>midl)l=midl;
//                else r=midr;
//            }
            int last;
            for(int r=l;r<=n;r++){
                //if(r<n&&agcdr[r+1]<ans&&ans)break;
                //if(r<n&&bgcdr[r+1]<ans&&ans)break;
                int val=solve(l,r);
                if(r!=l&&val<last)break;
                last=val;
                if(val==ans)num++;
                if(val>ans){
                    ans=val;
                    num=1;
                }
            }
        }cout<<ans<<" "<<num<<"\n";
    }
    return 0;
}
/*
1
2
18 13
15 20
*/

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
8
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
N=200010

T=0;n=0
a=[0 for i in range(N)]
b=[0 for i in range(N)]
prea=[0 for i in range(N)]
preb=[0 for i in range(N)]
sufa=[0 for i in range(N)]
sufb=[0 for i in range(N)]
gcda=[[0 for i in range(20)] for i in range(N)]
gcdb=[[0 for i in range(20)] for i in range(N)]
f=[0 for i in range(N)];

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

def get(l,r,t):
    len=0
    for i in range(20,-1,-1):
        if (1<<i)<=r-l+1:
            len=i
            break
    if t==0:
        return gcd(gcda[l][len],gcda[r-(1<<len)+1][len])
    else:
        return gcd(gcdb[l][len],gcdb[r-(1<<len)+1][len])

if __name__=='__main__':
    T=int(input())
    while T>0:
        n=int(input())
        a[1:n+1]=list(map(int,input().split()))
        b[1:n+1]=list(map(int,input().split()))
        sufa[0]=sufb[0]=0
        for i in range(1,n+1):
            prea[i]=gcd(prea[i-1],a[i])
            preb[i]=gcd(preb[i-1],b[i])
        sufa[n+1]=sufb[n+1]=0
        for i in range(n,0,-1):
            sufa[i]=gcd(sufa[i+1],a[i])
            sufb[i]=gcd(sufb[i+1],b[i])
        for i in range(1,n+1):
            gcda[i][0]=a[i];gcdb[i][0]=b[i]
        for len in range(1,20):
            for i in range(1,n+1):
                if (1<<len)<=n-i+1:
                    gcda[i][len]=gcd(gcda[i][len-1],gcda[i+(1<<(len-1))][len-1])
                    gcdb[i][len]=gcd(gcdb[i][len-1],gcdb[i+(1<<(len-1))][len-1])
                else:
                    gcda[i][len]=gcdb[i][len]=0
        if n>=100:
            nums=[]
            nums.append(-1);nums.append(0)
            maxv=0
            for r in range(1,n+1):
                for i in range(1,nums.size()):
                    t0=get(nums[i]+1,r,0);t1=get(nums[i]+1,r,1)
                    temp=gcd(gcd(prea[nums[i]],t1),sufa[r+1])+gcd(gcd(preb[nums[i]],t0),sufb[r+1])
                    maxv=max(maxv,temp)
                if prea[r]==prea[r-1] and preb[r]==preb[r-1]:
                    nums.pop_back()
                nums.push_back(r)
            ans=0
            for i in range(1,n+1):
               if gcd(prea[i],sufb[i+1])+gcd(preb[i],sufa[i+1])==maxv:
                    ans+=1
            S=set()
            for i in range(1,a[1]+1):
                if i*i>a[1]:
                    break
                if a[1]%i==0:
                    S.add(i);S.add(a[1]/i)
            for u in S:
                if u>=maxv or b[1]%(maxv-u)!=0:
                    continue
                v=maxv-u
                f[1]=0
                for i in range(2,n+1):
                    f[i]=0
                    if a[i]%v==0 and b[i]%u==0:
                        f[i]=f[i-1]
                    if a[i]%v==0 and b[i]%u==0 and prea[i-1]%u==0 and preb[i-1]%v==0:
                        f[i]+=1
                    if sufa[i+1]%u==0 and sufb[i+1]%v==0:
                        ans+=f[i]
            print("%d %d"%(maxv,ans))
        else:
            maxv=0
            ans=0
            for l in range(1,n+1):
                for r in range(l,n+1):
                    t0=get(l,r,0);t1=get(l,r,1)
                    temp=gcd(gcd(prea[l-1],t1),sufa[r+1])+gcd(gcd(preb[l-1],t0),sufb[r+1])
                    if temp>maxv:
                        maxv=temp
                        ans=1
                    elif temp==maxv:
                        ans+=1
            print("%d %d"%(maxv,ans))
        T-=1

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4
1 2 3 4
4 3 2 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
import math
from itertools import combinations

def gcd(arr):
    result = arr[0]
    for num in arr[1:]:
        result = math.gcd(result, num)
    return result

def max_gcd_and_ways(n, a, b):
    max_sum = 0
    ways = 0

    # Check all possible subarrays
    for l in range(n):
        for r in range(l, n):
            # Swap elements in the subarray [l, r]
            temp_a = a[:]
            temp_b = b[:]
            for i in range(l, r + 1):
                temp_a[i], temp_b[i] = temp_b[i], temp_a[i]

            # Calculate GCDs after swapping
            gcd_a = gcd(temp_a)
            gcd_b = gcd(temp_b)
            current_sum = gcd_a + gcd_b

            # Update max_sum and ways if necessary
            if current_sum > max_sum:
                max_sum = current_sum
                ways = 1
            elif current_sum == max_sum:
                ways += 1

    return max_sum, ways

# Read input
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    max_sum, ways = max_gcd_and_ways(n, a, b)
    print(max_sum, ways)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
5
1 2 3 4 5
6 7 8 9 10
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
import java.util.Scanner;
import java.util.Arrays;

public class MaxGCD {
    public static int gcd(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }

    public static int computeGCD(int[] arr) {
        int result = arr[0];
        for (int num : arr) {
            result = gcd(result, num);
        }
        return result;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();

        while (t-- > 0) {
            int n = scanner.nextInt();
            int[] a = new int[n];
            int[] b = new int[n];

            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
            }
            for (int i = 0; i < n; i++) {
                b[i] = scanner.nextInt();
            }

            int maxGCDSum = computeGCD(a) + computeGCD(b);
            int count = 0;

            // Check all pairs (l, r)
            for (int l = 0; l < n; l++) {
                for (int r = l; r < n; r++) {
                    // Create new arrays after swap
                    int[] newA = new int[n];
                    int[] newB = new int[n];
                    System.arraycopy(a, 0, newA, 0, l);
                    System.arraycopy(b, l, newA, l, r - l + 1);
                    System.arraycopy(a, r + 1, newA, r + 1, n - r - 1);
                    System.arraycopy(b, 0, newB, 0, l);
                    System.arraycopy(a, l, newB, l, r - l + 1);
                    System.arraycopy(b, r + 1, newB, r + 1, n - r - 1);

                    int currentGCDSum = computeGCD(newA) + computeGCD(newB);

                    if (currentGCDSum > maxGCDSum) {
                        maxGCDSum = currentGCDSum;
                        count = 1;
                    } else if (currentGCDSum == maxGCDSum) {
                        count++;
                    }
                }
            }

            System.out.println(maxGCDSum + " " + count);
        }

        scanner.close();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
4
1 2 3 4
4 3 2 1
2
1 2
2 1
8
1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(reader.readLine());
		StringBuilder result = new StringBuilder();

		while (t-- > 0) {
			int n = Integer.parseInt(reader.readLine());
			int[] a = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
			int[] b = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

			int[] prefixA = new int[n + 1];
			int[] prefixB = new int[n + 1];
			int[] suffixA = new int[n + 2];
			int[] suffixB = new int[n + 2];

			for (int i = 1; i <= n; i++) {
				prefixA[i] = gcd(prefixA[i - 1], a[i - 1]);
				prefixB[i] = gcd(prefixB[i - 1], b[i - 1]);
			}

			for (int i = n; i >= 1; i--) {
				suffixA[i] = gcd(suffixA[i + 1], a[i - 1]);
				suffixB[i] = gcd(suffixB[i + 1], b[i - 1]);
			}

			long maxGcdSum = gcd(prefixA[n], prefixB[n]);
			int count = 1;

			for (int l = 1; l <= n; l++) {
				for (int r = l; r <= n; r++) {

					int newGcdA = gcd(prefixA[l - 1], suffixA[r + 1]);
					int newGcdB = gcd(prefixB[l - 1], suffixB[r + 1]);

					for (int i = l; i <= r; i++) {
						newGcdA = gcd(newGcdA, b[i - 1]);
						newGcdB = gcd(newGcdB, a[i - 1]);
					}

					long currentGcdSum = (long) newGcdA + newGcdB;

					if (currentGcdSum > maxGcdSum) {
						maxGcdSum = currentGcdSum;
						count = 1;
					}
					else if (currentGcdSum == maxGcdSum) {
						count++;
					}
				}
			}

			result.append(maxGcdSum).append(" ").append(count).append("\n");
		}

		System.out.print(result);
	}

	private static int gcd(int a, int b) {
		while (b != 0) {
			int temp = b;
			b = a % b;
			a = temp;
		}
		return a;
	}

}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3
4
1 2 3 4
4 3 2 1
2
10 10
20 20
3
1 1 1
2 2 2
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;

        vi a(n), b(n);
        for(int i = 0; i < n; i++)
            cin >> a[i];
        for(int i = 0; i < n; i++)
            cin >> b[i];

        vector<unordered_map<int, unordered_set<int>>> dpa(3, unordered_map<int, unordered_set<int>>()), dpb(3, unordered_map<int, unordered_set<int>>());
        dpa[0][a[0]].insert(b[0]);

        for(int i = 1; i < n; i++) {
            int tst = 0;
            for(const auto &k : dpa[0]) {
                int ka = __gcd(k.first, a[i]);
                int kb = __gcd(k.first, b[i]);
                for(const auto &v : k.second) {
                    assert(++tst < 140);
                    dpb[0][ka].insert(__gcd(v, b[i]));
                    dpb[1][kb].insert(__gcd(v, a[i]));
                }
            }
            tst = 0;
            for(const auto &k : dpa[1]) {
                int ka = __gcd(k.first, a[i]);
                int kb = __gcd(k.first, b[i]);
                for(const auto &v : k.second) {
                    assert(++tst < 140);
                    dpb[1][kb].insert(__gcd(v, a[i]));
                    dpb[2][ka].insert(__gcd(v, b[i]));
                }
            }
            tst = 0;
            for(const auto &k : dpa[2]) {
                int ka = __gcd(k.first, a[i]);
                for(const auto &v : k.second) {
                    // assert(++tst < 140);
                    dpb[2][ka].insert(__gcd(v, b[i]));
                }
            }

            swap(dpa, dpb);

            dpb[0].clear();
            dpb[1].clear();
            dpb[2].clear();
        }

        int ga = 1, gb = 1;
        for(const auto &k : dpa[0]) {
            for(const auto &v : k.second) {
                if(k.first + v > ga + gb) {
                    ga = k.first;
                    gb = v;
                }
            }
        }
        for(const auto &k : dpa[1]) {
            for(const auto &v : k.second) {
                if(k.first + v > ga + gb) {
                    ga = k.first;
                    gb = v;
                }
            }
        }
        for(const auto &k : dpa[2]) {
            for(const auto &v : k.second) {
                if(k.first + v > ga + gb) {
                    ga = k.first;
                    gb = v;
                }
            }
        }

        bool snd = false;
        ll ans = 0, tmp = 0;

        {
            vector<array<ll, 3>> dp(n + 1, {0ll, 0ll, 0ll});
            dp[0][0] = 1ll;

            for(int i = 1; i <= n; i++) {
                tmp = 0;

                if(a[i - 1] % ga == 0 && b[i - 1] % gb == 0) {
                    dp[i][0] += dp[i - 1][0];
                    dp[i][2] += dp[i - 1][2] + dp[i - 1][1];
                    tmp += 1;
                }

                if(a[i - 1] % gb == 0 && b[i - 1] % ga == 0) {
                    dp[i][1] += dp[i - 1][1] + dp[i - 1][0];
                    tmp += 2;
                }

                if(tmp != 3)
                    snd = true;
            }

            ans += dp.back()[1] + dp.back()[2];
        }

        if(snd) {
            swap(ga, gb);

            vector<array<ll, 3>> dp(n + 1, {0ll, 0ll, 0ll});
            dp[0][0] = 1ll;

            for(int i = 1; i <= n; i++) {
                if(a[i - 1] % ga == 0 && b[i - 1] % gb == 0) {
                    dp[i][0] += dp[i - 1][0];
                    dp[i][2] += dp[i - 1][2] + dp[i - 1][1];
                }

                if(a[i - 1] % gb == 0 && b[i - 1] % ga == 0) {
                    dp[i][1] += dp[i - 1][1] + dp[i - 1][0];
                }
            }

            ans += dp.back()[1] + dp.back()[2];
        }

        cout << ga + gb << " " << ans << "\n";
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
4
1 2 3 4
5 6 7 8
2
1 2
3 4
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize "-Ofast"
#pragma GCC optimize "-funroll-loops"
using namespace std;
#define ll long long
// #define int ll
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define sz(x) ((int)x.size())
typedef pair<int, ll> pil;
const ll inf=3e18;
const int maxn=1e6+10;

int n;
int a[maxn];
int b[maxn];

map<basic_string<int>, pil> memo;

pil recursion(int i, int g1, int g2, int swaps)
{
    if(i == n)
        return {g1 + g2, (swaps?1:0)};
    if(g1 == 1 && g2 == 1)
    {
        ll q;
        if(swaps == 2) q = 1;
        else if(swaps == 1) q = 1 + n - i;
        else q = n - i + (ll)(n - i) * (n - i - 1) / 2;
        return {2, q};
    }
    if(memo.count({i, g1, g2, swaps}))
        return memo[{i, g1, g2, swaps}];
    if(swaps == 2)
        return memo[{i, g1, g2, swaps}] = recursion(i+1, __gcd(g1, a[i+1]), __gcd(g2, b[i+1]), 2);
    if(swaps == 1)
    {
        pil pr1 = recursion(i+1, __gcd(g1, b[i+1]), __gcd(g2, a[i+1]), 1);
        pil pr2 = recursion(i+1, __gcd(g1, a[i+1]), __gcd(g2, b[i+1]), 2);
        if(pr1.ff > pr2.ff)
            return pr1;
        else if(pr2.ff > pr1.ff)
            return pr2;
        return memo[{i, g1, g2, swaps}] = {pr1.ff, pr1.ss + pr2.ss};
    }
    // swaps == 0
    pil pr1 = recursion(i+1, __gcd(g1, a[i+1]), __gcd(g2, b[i+1]), 0);
    pil pr2 = recursion(i+1, __gcd(g1, b[i+1]), __gcd(g2, a[i+1]), 1);
    if(pr1.ff > pr2.ff)
        return pr1;
    else if(pr2.ff > pr1.ff)
        return pr2;
    return memo[{i, g1, g2, swaps}] = {pr1.ff, pr1.ss + pr2.ss};
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);cin.tie(0);

    int T; cin>> T;
    while(T--)
    {
        memo.clear();
        cin>> n;
        for(int i=1; i<=n; i++)
            cin>> a[i];
        for(int i=1; i<=n; i++)
            cin>> b[i];
        pil ans = recursion(0, 0, 0, 0);
        cout<< ans.ff<< " "<< ans.ss<< "\n";
    }

    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
3
4 6 8
3 6 9
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
import sys
from collections import defaultdict

def gcd(y, x):
	return y if x % y == 0 else gcd(x % y, y)

input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	b = [*map(int, input().split())]
	g01 = a[0] #always keep a[0] and b[0] unchanged
	g02 = b[0] #haven't reversed yet
	pin = {} #(gcd1, gcd2): count, currently in the reversed interval
	pout = {} #(gcd1, gcd2): count, alredy out of the reversed interval
	for i in range(1, n):
		tmp1, tmp2 = defaultdict(int), defaultdict(int)
		tmp1[(gcd(g01, b[i]), gcd(g02, a[i]))] = 1 #start reverse now, do not reverse have only 1 way
		g01 = gcd(g01, a[i])
		g02 = gcd(g02, b[i])
		for g1, g2 in pin:
			tmp1[(gcd(g1, b[i]), gcd(g2, a[i]))] += pin[(g1, g2)]
			tmp2[(gcd(g1, a[i]), gcd(g2, b[i]))] += pin[(g1, g2)]
		for g1, g2 in pout:
			tmp2[(gcd(g1, a[i]), gcd(g2, b[i]))] += pout[(g1, g2)]
		pin = tmp1
		pout = tmp2
	mx = g01 + g02 #do not reverse is not allowed, means reverse all indexes instead
	cnt = 1
	for key in pin:
		v = sum(key)
		if v > mx:
			mx = v
			cnt = pin[key] * 2 #reverse [0...l] and [r...n-1] are both valid
		elif v == mx:
			cnt += pin[key] * 2
	for key in pout:
		v = sum(key)
		if v > mx:
			mx = v
			cnt = pout[key]
		elif v == mx:
			cnt += pout[key]
	print(mx, cnt)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
5
8
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1
4
2 3 4 5
5 4 3 2
2
1 1
1 1
8
2 4 6 8 10 12 14 16
16 14 12 10 8 6 4 2
2
2 2
2 2
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
from math import gcd
from collections import defaultdict
#from bisect import bisect
#from heapq import heappush,heappop
#from random import randint

from sys import stdin,stdout
input=lambda:stdin.readline().rstrip()
print=lambda *x,sep=' ',end='\n':stdout.write(sep.join(map(str,x))+end)

def out(l):
    print(' '.join(map(str,l)))

def yes():
    print('Yes')

def no():
    print('No')

def alice():
    print('Alice')

def bob():
    print('Bob')

def solve():
    n=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    dp={(0,a[0],b[0]):1,(1,b[0],a[0]):1,(2,b[0],a[0]):1}
    for i in range(1,n):
        temp=defaultdict(int)
        for ph,ga,gb in dp:
            cnt=dp[ph,ga,gb]
            if ph==0:
                temp[(0,gcd(ga,a[i]),gcd(gb,b[i]))]+=cnt
                temp[(1,gcd(ga,b[i]),gcd(gb,a[i]))]+=cnt
                temp[(2,gcd(ga,b[i]),gcd(gb,a[i]))]+=cnt
            elif ph==1:
                temp[(1,gcd(ga,b[i]),gcd(gb,a[i]))]+=cnt
                temp[(2,gcd(ga,b[i]),gcd(gb,a[i]))]+=cnt
            else:
                temp[(2,gcd(ga,a[i]),gcd(gb,b[i]))]+=cnt
        dp=temp
    maxi=0
    ways=0
    for ph,ga,gb in dp:
        if ph==2:
            if maxi<ga+gb:
                maxi=ga+gb
                ways=dp[ph,ga,gb]
            elif maxi==ga+gb:
                ways+=dp[ph,ga,gb]
    print(maxi,ways)

for _ in range(int(input())):
    solve()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
5
8
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1
4
1 2 3 4
4 3 2 1
2
1 2
2 1
8
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1
2
1 1
1 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Alter the GCD
time_limit_ms: 4000
memory_limit_mb: 256
Description: You are given two arrays $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

You must perform the following operation exactly once:

  * choose any indices $l$ and $r$ such that $1 \le l \le r \le n$;    * swap $a_i$ and $b_i$ for all $i$ such that $l \leq i \leq r$.

Find the maximum possible value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ 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 \le t \le 10^5$), 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 \le n \le 2 \cdot 10^5$), representing the number of integers in each array.

In the next line, you are given $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

In the last line, you are given $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

The sum of values of $n$ over all test cases does not exceed $5 \cdot 10^5$.

Output: For each test case, output a line with two integers: the maximum value of $\text{gcd}(a_1, a_2, \ldots, a_n) + \text{gcd}(b_1, b_2, \ldots, b_n)$ after performing the operation exactly once, and the number of ways.

Examples:
input:
5
8
11 4 16 17 3 24 25 8
8 10 4 21 17 18 25 21
4
6 4 24 13
15 3 1 14
2
13 14
5 8
8
20 17 15 11 21 10 3 7
9 9 4 20 14 9 13 1
2
18 13
15 20
output:
2 36
3 2
2 3
2 36
6 1

Note: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.

In the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.

Buggy Code:
import java.util.*;

public class Main {
    static class Tuple {
        int ph, g1, g2;

        Tuple(int ph, int g1, int g2) {
            this.ph = ph;
            this.g1 = g1;
            this.g2 = g2;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Tuple tuple = (Tuple) o;
            return ph == tuple.ph && g1 == tuple.g1 && g2 == tuple.g2;
        }

        @Override
        public int hashCode() {
            return Objects.hash(ph, g1, g2);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        while (T-- > 0) {
            int n = sc.nextInt();
            int[] a = new int[n];
            int[] b = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = sc.nextInt();
            }
            for (int i = 0; i < n; i++) {
                b[i] = sc.nextInt();
            }

            Map<Tuple, Long> dp = new HashMap<>();
            dp.put(new Tuple(0, a[0], b[0]), 1L);
            dp.put(new Tuple(1, b[0], a[0]), 1L);
            dp.put(new Tuple(2, b[0], a[0]), 1L);

            for (int i = 1; i < n; i++) {
                Map<Tuple, Long> dp2 = new HashMap<>();
                int ai = a[i], bi = b[i];
                for (Map.Entry<Tuple, Long> entry : dp.entrySet()) {
                    Tuple t = entry.getKey();
                    long f = entry.getValue();

                    if (t.ph == 2) {
                        Tuple newTuple = new Tuple(2, gcd(ai, t.g1), gcd(bi, t.g2));
                        dp2.put(newTuple, dp2.getOrDefault(newTuple, 0L) + f);
                        continue;
                    }
                    if (t.ph == 1) {
                        Tuple newTuple1 = new Tuple(1, gcd(bi, t.g1), gcd(ai, t.g2));
                        Tuple newTuple2 = new Tuple(2, gcd(bi, t.g1), gcd(ai, t.g2));
                        dp2.put(newTuple1, dp2.getOrDefault(newTuple1, 0L) + f);
                        dp2.put(newTuple2, dp2.getOrDefault(newTuple2, 0L) + f);
                        continue;
                    }
                    Tuple newTuple0 = new Tuple(0, gcd(ai, t.g1), gcd(bi, t.g2));
                    Tuple newTuple1 = new Tuple(1, gcd(bi, t.g1), gcd(ai, t.g2));
                    Tuple newTuple2 = new Tuple(2, gcd(bi, t.g1), gcd(ai, t.g2));
                    dp2.put(newTuple0, dp2.getOrDefault(newTuple0, 0L) + f);
                    dp2.put(newTuple1, dp2.getOrDefault(newTuple1, 0L) + f);
                    dp2.put(newTuple2, dp2.getOrDefault(newTuple2, 0L) + f);
                }
                dp = dp2;
            }

            Map<Integer, Long> res = new HashMap<>();
            for (Map.Entry<Tuple, Long> entry : dp.entrySet()) {
                Tuple t = entry.getKey();
                long f = entry.getValue();

                if (t.ph != 2) continue;
                int sum = t.g1 + t.g2;
                res.put(sum, res.getOrDefault(sum, 0L) + f);
            }

            int bestSum = Collections.max(res.keySet());
            long bestCount = res.get(bestSum);
            System.out.println(bestSum + " " + bestCount);
        }
    }

    private static int gcd(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
5
1
1
1
2
1 2
2 1
3
1 2 3
3 2 1
4
1 2 3 4
4 3 2 1
5
1 2 3 4 5
5 4 3 2 1
```