## Problem Statement-

Monocarp had a sequence consisting of integers . He painted the elements into two colors, red and blue; elements were painted red, all other elements were painted blue.

After painting the elements, he has written two sequences and . The sequence consisted of all red elements of in the order they appeared in ; similarly, the sequence consisted of all blue elements of in the order they appeared in as well.

Unfortunately, the original sequence was lost, and Monocarp only has the sequences and . He wants to restore the original sequence. In case there are multiple ways to restore it, he wants to choose a way to restore that maximizes the value of

Help Monocarp to calculate the maximum possible value of .

The first line contains one integer () — the number of test cases. Then the test cases follow. Each test case consists of four lines.

The first line of each test case contains one integer ().

The second line contains integers ().

The third line contains one integer ().

The fourth line contains integers ().

For each test case, print one integer — the maximum possible value of .

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

13 13 0 0

In the explanations for the sample test cases, red elements are marked as bold.

In the first test case, one of the possible sequences is .

In the second test case, one of the possible sequences is .

In the third test case, one of the possible sequences is .

In the fourth test case, one of the possible sequences is .

Solution-

## Comments

## Post a Comment