CF2173B Niko's Tactical Cards

Description

Niko is playing a game. Her score is denoted by an integer $ k $ which is $ 0 $ initially. The game has $ n $ turns. On the $ i $ -th turn, Niko is given a red card with an integer $ a_i $ on it, as well as a blue card with an integer $ b_i $ on it. She must choose exactly one of the cards and update her score according to her choice: - If she chooses the red card, her score becomes $ k - a_i $ , where $ k $ is her score before the turn. - If she chooses the blue card, her score becomes $ b_i - k $ , where $ k $ is her score before the turn. After this, the game proceeds to the next turn, or ends if it is the $ n $ -th turn. Your task is to find the maximum possible score Niko can obtain at the end of the game.

Input Format

Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 10^3 $ ). The description of the test cases follows. The first line of each test case contains a single integer $ n $ ( $ 1 \le n \le 10^5 $ ) — the number of turns. The second line of each test case contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ -10^9 \le a_i \le 10^9 $ ). The third line of each test case contains $ n $ integers $ b_1, b_2, \ldots, b_n $ ( $ -10^9 \le b_i \le 10^9 $ ). It is guaranteed that the sum of $ n $ over all test cases does not exceed $ 10^5 $ .

Output Format

For each test case, output a single integer — the maximum possible score Niko can obtain at the end of the game.

Explanation/Hint

In the first test case, one optimal strategy is as follows: Turn0123Card Chosen—BlueRedRedScore $ 0 $ $ -3 - 0 = -3 $ $ -3 - (-8) = 5 $ $ 5 - (-1) = 6 $ In the second test case, one optimal strategy is as follows: Turn012345Card Chosen—BlueBlueBlueBlueRedScore $ 0 $ $ -5 $ $ 8 $ $ -9 $ $ 13 $ $ 12 $