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 ≤ 10^9
1 ≤ K ≤ max{R, G, B}


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=int(raw_input())
for la in range(0,t):
    a,b,c=raw_input().split()
    a=int(a)
    b=int(b)
    c=int(c)
    mn=int(raw_input())
    mn-=1
    ans=0
    if a<=mn:
        ans+=a
    else:
        ans+=mn
    if b<=mn:
        ans+=b
    else:
        ans+=mn
    if c<=mn:
        ans+=c
    else:
        ans+=mn
    print ans+1