ACM-ICPC Indonesia National Contest 2010

Problem D

Sum to Zero

Time Limit: 10s

Given three sets of integers of the same size: A, B and C. Your task is to calculate how many triplet {i, j, k} such that A i + B j + C k = 0.


Input

The first line of input contains an integer T (1 ≤ T ≤ 100) the number of cases. Each case begins with an integer N (1 ≤ N ≤ 2,000) the size of each set of integer. The next three lines each contains N integers range from -1,000,000,000 to 1,000,000,000. Each line represent A, B and C respectively.

Output

For each test case, output in a line the number of different triplets.



Sample InputOutput for Sample Input
2
2
0 3
-1 5
0 1
4
2 7 -3 9
-1 -5 4 6
-2 -7 8 -3
1
3

Explanation for the 1st sample input.

There is only one triplet that sums to zero: {0, 0, 1} which corresponds to 0 + (-1) + 1 = 0.


Explanation for the 2nd sample input.

There are three triplets that sum to zero: