Today a plane was hijacked by a maniac. All the passengers of the flight are taken as hostage. Chef is also one of them.
He invited one of the passengers to play a game with him. If he loses the game, he will release all the passengers, otherwise he will kill all of them. A high risk affair it is.
Chef volunteered for this tough task. He was blindfolded by Hijacker. Hijacker brought a big black bag from his pockets. The contents of the bag is not visible. He tells Chef that the bag contains R red, G green and B blue colored balloons.
Hijacker now asked Chef to take out some balloons from the box such that there are at least K balloons of the same color and hand him over. If the taken out balloons does not contain at least K balloons of the same color, then the hijacker will shoot everybody. Chef is very scared and wants to leave this game as soon as possible, so he will draw the minimum number of balloons so as to save the passengers. Can you please help scared Chef to find out the minimum number of balloons he should take out.
-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. 
The first line of each test case contains a three space-separated integers R, G and B. 
The second line contains only one integer K.
-----Output-----
For each test case, output a single line containing one integer - the minimum number of balloons Chef need to take out from the bag.
-----Constraints-----
- 1 ≤ T ≤ 1000
- 1 ≤ R, G, B ≤ 109
- 1 ≤ K ≤ max{R, G, B}
-----Subtasks-----
- Subtask 1 (44 points): 1 ≤ R, G, B ≤ 10
- Subtask 2 (56 points):  No additional constraints
-----Example-----
Input:
2
3 3 3
1
3 3 3
2
Output:
1
4
-----Explanation-----
Example case 2. In the worst-case scenario first three balloons will be of the three different colors and only after fourth balloon Chef will have two balloons of the same color. So, Chef might need to fetch 4 balloons
T = eval(input())

for _ in range(T):
 col = sorted(map(int, input().split()))
 k = eval(input())
 ans = min(col[0], k-1) + min(col[1], k-1) + min(col[2], k-1) + 1
 print(ans)
T = eval(input())

for _ in range(T):
 col = sorted(map(int, input().split()))
 k = eval(input())
 ans = min(col[0], k-1) + min(col[1], k-1) + min(col[2], k-1) + 1
 print(ans)