N=int(eval(input()))

*A,=sorted(map(int,input().split()))

*B,=sorted(map(int,input().split()))

*C,=sorted(map(int,input().split()))



lenc=len(C)



from bisect import *



cnt=0

for b in B:

    in_a = bisect_left(A, b)

    in_c = bisect_right(C, b)

    cnt+= in_a*(lenc-in_c)



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

f=lambda:sorted(map(int,input().split()))

*A,=f()

*B,=f()

*C,=f()

from bisect import *

print((sum([bisect_left(A, b)*(N-bisect_right(C, b)) for b in B])))
N = int(eval(input()))
(*A,) = sorted(map(int, input().split()))
(*B,) = sorted(map(int, input().split()))
(*C,) = sorted(map(int, input().split()))
lenc = len(C)
from bisect import *

cnt = 0
for b in B:
    in_a = bisect_left(A, b)
    in_c = bisect_right(C, b)
    cnt += in_a * (lenc - in_c)
print(cnt)

N = int(eval(input()))
f = lambda: sorted(map(int, input().split()))
(*A,) = f()
(*B,) = f()
(*C,) = f()
from bisect import *

print((sum([bisect_left(A, b) * (N - bisect_right(C, b)) for b in B])))

-(*A,) = sorted(map(int, input().split())) -(*B,) = sorted(map(int, input().split())) -(*C,) = sorted(map(int, input().split())) -lenc = len(C) +f = lambda: sorted(map(int, input().split())) +(*A,) = f() +(*B,) = f() +(*C,) = f() -cnt = 0 -for b in B: -    in_a = bisect_left(A, b) -    in_c = bisect_right(C, b) -    cnt += in_a * (lenc - in_c) -print(cnt) +print((sum([bisect_left(A, b) * (N - bisect_right(C, b)) for b in B])))