Four Integers Summing to Zero

No attempts yetTime limit12sMemory limit1024 MB

Problem

You are given four integer arrays AA, BB, CC, and DD, all of the same size.

Write a program that counts the number of tuples (a,b,c,d)(a, b, c, d) such that A[a]+B[b]+C[c]+D[d]=0A[a] + B[b] + C[c] + D[d] = 0. Here aa, bb, cc, and dd are indices from 00 to n1n-1, choosing one element independently from each of the four arrays.

Input

The first line contains the array size nn (1n4000)(1 \le n \le 4000). Each of the next nn lines contains the integers belonging to AA, BB, CC, and DD, separated by spaces; the four integers on the ii-th line are A[i]A[i], B[i]B[i], C[i]C[i], and D[i]D[i] in that order. The absolute value of every integer is at most 2282^{28}.

Output

Print the number of tuples (a,b,c,d)(a, b, c, d) whose sum is 00.