#Lutece0242. Game

Game

Migrated from Lutece 242 Game

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Consider the following two-player game played with a sequence of N positive integers (2N1000)(2 \leq N \leq 1000) laid onto a game board. Player 11 starts the game. The players move alternately by selecting a number from either the left or the right end of the sequence. That number is then deleted from the board, and its value is added to the score of the player who selected it. A player wins if his sum is greater than his opponents.

Write a program that implements the optimal strategy. The optimal strategy yields maximum points when playing against the best possible opponent. Your program must further implement an optimal strategy for player 22.

Input

In the first line is one integer T(T100)T(T \leq 100)

TT cases follow. For each case, the first line contains one integer nn, the size of the board. Then the second line give you nn integers (no more than 10001000) that are the contents of the game board, from left to right.

Output

For each case print one line with two integer v1v_1 and v2v_2 means the maximum points player 11 and player 22 can get.

Samples

1
6
4 7 2 9 5 2
18 11

Resources

modified from IOI'96 by lcq