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
T=input()
while T:
      count=0
      T-=1
      n,a,b,c=[int(x) for x in raw_input().split()]
      if a+b+c<=n:
            count=(a+1)*(b+1)*(c+1)
      else:
            for i in range(0,min(a,n)+1):
                  if (b+c<=n-i):
                        count+=(b+1)*(c+1)
                  elif (b>=n-i and c>=n-i):
                        count+=(n+1-i)*(n+2-i)/2
                  elif (b<=n-i and c>=n-i) or (b>=n-i and c<=n-i):
                        count+=((n+1-i)*(n+2-i)/2)-((n+1-i-min(c,b))*(n-i-min(c,b))/2)
                  else:
                        count+=(((min(b,c)+1)*(min(b,c)+2)/2) + ((n-i-min(b,c))*(min(b,c)+1)) - ((n-i-max(b,c))*(n+1-i-max(b,c))/2))
      print count