You are a participant in a Quiz Competetion organized in Pantheon.You have 2 opponents from 2k10 batch Shikhar Atri
and Raghvesh Sharan and Trust me they are bloody Good.Throughout the game you and the other two competitors have gained some points.
Now at the end of the game the three of you are given a final question.Before you hear the question you have to wager some points.
If a contestant answers the question correctly he/she will be awarded the ponits equal to his wager and the same amount of points ( wager) will
be deducted in case of a wrong answer.The participant who ends up with highest score after the final question will end up winning the game.

Now it is time for you to place your wager.You can bet any amount between 0 and your current score , both inclusive.You are given your current score followed by the current scores of both your opponents and also their wagers.You have to place a wager which maximizes your probability
of winning the Quiz.You can assume that you and both the other participants each independently have a 50% chance to answer correctly.

If multiple wagers can give you the highest probabilty of winning , choose the minimum one.

Input
Firts line contains number of test cases T <=1000
Now each of the following T lines contains 5 integers on each line.
5 integers represnt your score followed by scores of your two opponents followed by wagers of your two opponents.
(score1,score2,score3,wager1,wager2)
All scores and wagres <=100000

Ouput
A single integer containing your minimum wager that maximizes you chances of winning.

constraints

0<=score1,score2,score3<=100000
wager1<=score2
wager2<=score3

Sample Input

2
100 100 100 25 75
10 50 60 30 41

Sample Output

76
0

Problem Setter: Arjun Singh Bhatia

Languages: Brain,C,C++,Java,Pascal,Perl,PHP,Python,Ruby,Text

Time Limit: 3 Second(s)
Score: 0 Point(s)
Input File Limit: 50000 Bytes

Mode Judge

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0