#K83357. Max Combined Mana Blossom Potency

    ID: 36179 Type: Default 1000ms 256MiB

Max Combined Mana Blossom Potency

Max Combined Mana Blossom Potency

You are given several test cases. For each test case, you are provided with two lists of integers representing the potency levels of different types of Mana Blossoms. The task is to determine the maximum combined potency by selecting one Mana Blossom from the first list and one from the second list. Mathematically, for each test case, if the first list is \(A = [a_1, a_2, \dots, a_N]\) and the second list is \(B = [b_1, b_2, \dots, b_M]\), then you need to compute:

[ \text{answer} = \max(A) + \max(B) ]

Output the result for each test case on a new line.

inputFormat

The first line contains an integer \(T\), the number of test cases. For each test case, the input is provided in the following four lines:

  • The first line contains an integer \(N\) denoting the number of Mana Blossoms in the first list.
  • The second line contains \(N\) space-separated integers representing the potency levels of the Mana Blossoms in the first list.
  • The third line contains an integer \(M\) denoting the number of Mana Blossoms in the second list.
  • The fourth line contains \(M\) space-separated integers representing the potency levels of the Mana Blossoms in the second list.

outputFormat

For each test case, output the maximum combined potency (i.e., the sum of the maximum elements from both lists) on a new line.

## sample
2
3
4 7 2
4
5 10 6 3
2
1 9
3
8 5 9
17

18

</p>