N = int(eval(input()))

A = list(map(int, input().split()))

B = list(map(int, input().split()))

C = list(map(int, input().split()))



A.sort()

B.sort()

C.sort()



from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort



ans = 0



for b in B:

    ans += bisect_left(A,b) * (N - bisect_right(C,b))



print(ans)
N = int(eval(input()))

A = list(map(int, input().split()))

B = list(map(int, input().split()))

C = list(map(int, input().split()))

A.sort()

B.sort()

C.sort()

from bisect import *

ans = 0

for b in B:

  a = bisect_left(A,b)

  c = N-bisect_right(C,b)

  ans += a*c

print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort

ans = 0
for b in B:
    ans += bisect_left(A, b) * (N - bisect_right(C, b))
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
from bisect import *

ans = 0
for b in B:
    a = bisect_left(A, b)
    c = N - bisect_right(C, b)
    ans += a * c
print(ans)

-from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort +from bisect import * -    ans += bisect_left(A, b) * (N - bisect_right(C, b)) +    a = bisect_left(A, b) +    c = N - bisect_right(C, b) +    ans += a * c