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()

import bisect as bi



ans=0



for i in B:

    ans+= bi.bisect_left(A,i) * (n-bi.bisect_right(C,i))

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()



import bisect as bi

ans=0

for i in range(n):

    q=B[i]

    oka= bi.bisect_left(A,q)

    okb= n- bi.bisect_right(C,q)

    ans+=oka*okb

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()
import bisect as bi

ans = 0
for i in B:
    ans += bi.bisect_left(A, i) * (n - bi.bisect_right(C, i))
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()
import bisect as bi

ans = 0
for i in range(n):
    q = B[i]
    oka = bi.bisect_left(A, q)
    okb = n - bi.bisect_right(C, q)
    ans += oka * okb
print(ans)

-for i in B: -    ans += bi.bisect_left(A, i) * (n - bi.bisect_right(C, i)) +for i in range(n): +    q = B[i] +    oka = bi.bisect_left(A, q) +    okb = n - bi.bisect_right(C, q) +    ans += oka * okb