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 sum_1_to_n(n):
	return (n+1)*n/2


T = int(raw_input())

while T>0:
	T-=1
	N,A,B,C = map(int, raw_input().split()) #map(lambda x: random.randint(0,250), range(4)) #
	
	"""
	if N >= A+B+C:
		print( (A+1)*(B+1)*(C+1) )
	else:
	"""
	A0=A
	B0=B
	C0=C
	if True:
		sum = 0
		A = min(A,N)
		B = min(B,N)
		C = min(C,N)
		for a in xrange(A+1):
			""" I need to abstract b's loop
			for b in xrange(B+1):
				c = max(0,N-a-b+1)
				sum+=min(c,C+1)
			"""
			c_0 = N-a
			if C<c_0:
				sum += (c_0 - C)*(C+1)
				sum += sum_1_to_n(C+1)
			else:
				sum += sum_1_to_n(c_0+1)
			if B<c_0:
				numero_magico = c_0-(B+1)
				if numero_magico > C:
					sum -= (numero_magico - C)*(C+1)
					sum -= sum_1_to_n(C+1)
				else:
					sum -= sum_1_to_n(numero_magico+1)
		print(sum)
		"""
		stpd = stupid(N,A0,B0,C0)
		if sum != stpd:
			print(sum, stpd, N, A0, B0, C0)
		"""