Hide

Problem F
Final Exam

In the final round of the Hunter Exam, candidates must prove their ability to process big data as well as geometry knowledge.

In the Examination Hall, the candidates can find three piles of segments:

  • The first pile has na segments, and the i-th segment has length Ai.

  • The second pile has nb segments, and the j-th segment has length Bj.

  • The third pile has nc segments, and the k-th segment has length Ck.

The candidates must quickly select three segments, one segment from each pile, such that:

  • The three segments can be used to form a right triangle.

  • The segment chosen from the third pile must be longest.

As the organizer of the Hunter Exam, you need to make sure that the difficulty is right for the final round. Thus you want to know the number of ways to select three segments, satisfying the conditions above?

Input

The first line of the input contains exactly three integers: na, nb and nc (1na,nb,nc3105).

The second line of the input contains exactly na integers — the lengths of the segments in the first pile.

The third line of the input contains exactly nb integers — the lengths of the segments in the second pile.

The fourth line of the input contains exactly nc integers — the lengths of the segments in the third pile.

All the lengths of the segments are between 1 and 3107, inclusive.

Output

Print exactly one integer — the number of triplets.

Explanation of sample test

There are 4 different ways to select three segments: (3,4,5), (3,4,5), (4,3,5) and (4,3,5).

Selecting (5,4,3) is not valid, as the segment from the third pile must be the longest segment.

Sample Input 1 Sample Output 1
3 2 3
3 4 5
4 3
5 5 3
4
Hide

Please log in to submit a solution to this problem

Log in