LogiQuest

188. Four Arrays Zero Sum

MediumHash MapMeet in the Middle

Four arrays A, B, C, D each have n integers. Count tuples (i, j, k, l) with A[i] + B[j] + C[k] + D[l] = 0.

Input format

Line 1: n Next 4 lines: arrays A, B, C, D

Output format

The count.

Example 1

Input

2
1 2
-2 -1
-1 2
0 2

Output

2

Example 2

Input

1
0
0
0
0

Output

1

Constraints

1 ≤ n ≤ 200

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…