Statement 

Given N,A,B,C, find how many solutions exist to the equation : a + b + c ≤ N, such that 0 ≤ a ≤ A, 0 ≤ b ≤ B, 0 ≤ c ≤ C.


Input 

The first line contains the number of test cases T. Each test case contains 4 integers, N,A,B,C. 0 ≤ N,A,B,C ≤ 2500


Output 

Output T lines, one for each test case.


Sample Input 

2
4 3 2 1
1 1 1 1


Sample Output 

20
4
def comb(n):
    if n>=0:
        n+=2
        return ((n**3 - n)/6)
    else:
        return 0
t=input()
while (t):
    num=map(int,raw_input().split())
    num[1]+=1
    num[2]+=1
    num[3]+=1
    x=comb(num[0])
    x1=comb(num[0]-num[1])
    x2=comb(num[0]-num[2])
    x3=comb(num[0]-num[3])
    x12=comb(num[0]-num[1]-num[2])
    x23=comb(num[0]-num[2]-num[3])
    x13=comb(num[0]-num[1]-num[3])
    x123=comb(num[0]-num[1]-num[2]-num[3])
    print (x-x1-x2-x3+x12+x13+x23-x123)
    t-=1