yet-another-amazing-game

Abhinav is master in game theory. He creates new games with a great logic and today he has created another one. He invites his best friend Ravi to play against him.

The rules of the game are, a set of N powers are given. Players start with initial power zero. In their turn, each player should choose a power from the set. A player can choose any power from the set that are only to either ends of the set. Once a power is chosen, it is removed from the set and its value is added to value of individual power of the player who chose it. The one who ends with maximum power wins the game.

Abhinav lets his friend Ravi to start the game always. Now you have to find who wins the game if both the players play optimally.
Input :
First line has an integer T(number of test cases).  
Each test case is a single line with first number denoting N, size of set of powers and N numbers follows in the same line.

Output :
For each test case, print who wins the game along with his power at the end of the game. If both the players get equal power, print "Tie"(without quotes).

Constraints :
1 ≤ T ≤ 250
1 ≤ N ≤ 1000
1 ≤ P ≤ 1000 (P is value of individual powers in the set).

Problem Setter : Vinay Kumar

SAMPLE INPUT
4
1 1
2 1 2
5 1 3 5 5 1
3 2 4 2

SAMPLE OUTPUT
Ravi 1
Ravi 2
Abhinav 8
Tie

Source: hackerearth | Difficulty: MEDIUM_HARD
Tags: Dynamic programming


Solutions: