codeforces#P1910E. Maximum Sum Subarrays

Maximum Sum Subarrays

Description

You are given two integer arrays $a$ and $b$, both of length $n$.

You can perform the following operation any number of times (possibly zero): swap $a_i$ and $b_i$.

Let $f(c)$ be the maximum sum of a contiguous subarray of the array $c$ (including the empty subsegment, which sum is $0$).

Your task is to calculate the maximum possible value of $f(a) + f(b)$, using the aforementioned operation any number of times.

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The first line of each test case contains a single integer $n$ ($1 \le n \le 2 \cdot 10^5$).

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($-10^9 \le a_i \le 10^9$).

The third line contains $n$ integers $b_1, b_2, \dots, b_n$ ($-10^9 \le b_i \le 10^9$).

The sum of $n$ over all test case doesn't exceed $2 \cdot 10^5$.

For each test case, print a single integer — the maximum possible value of $f(a) + f(b)$, using the aforementioned operation any number of times.

Input

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The first line of each test case contains a single integer $n$ ($1 \le n \le 2 \cdot 10^5$).

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($-10^9 \le a_i \le 10^9$).

The third line contains $n$ integers $b_1, b_2, \dots, b_n$ ($-10^9 \le b_i \le 10^9$).

The sum of $n$ over all test case doesn't exceed $2 \cdot 10^5$.

Output

For each test case, print a single integer — the maximum possible value of $f(a) + f(b)$, using the aforementioned operation any number of times.

3
3
2 -1 3
-4 0 1
6
4 2 -6 1 6 -4
-6 -2 -3 7 -3 2
2
-2 -5
0 -1
6
21
0