N = int(eval(input()))



L = []

L.extend(((int(x), 3)  for x in input().split()))

L.extend(((int(x), 2)  for x in input().split()))

L.extend(((int(x), 1)  for x in input().split()))



L = sorted(L, reverse=True)



cnt_C = 0

cnt_B = 0

cnt_A = 0

for x, i in L:

    if i == 1:

        cnt_C += 1

    elif i == 2:

        cnt_B += cnt_C

    elif i == 3:

        cnt_A += cnt_B



print(cnt_A)

N = int(eval(input()))



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

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

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



cur_l = 0

cur_r = 0

p = 0

for cur_mid in B:

    while cur_l < len(A):

        if A[cur_l] >= cur_mid:

            break

        cur_l += 1

    while cur_r < len(C):

        if cur_mid < C[cur_r]:

            break

        cur_r += 1

    p += cur_l * (len(C) - cur_r)



print(p)

N = int(eval(input()))
L = []
L.extend(((int(x), 3) for x in input().split()))
L.extend(((int(x), 2) for x in input().split()))
L.extend(((int(x), 1) for x in input().split()))
L = sorted(L, reverse=True)
cnt_C = 0
cnt_B = 0
cnt_A = 0
for x, i in L:
    if i == 1:
        cnt_C += 1
    elif i == 2:
        cnt_B += cnt_C
    elif i == 3:
        cnt_A += cnt_B
print(cnt_A)

N = int(eval(input()))
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
cur_l = 0
cur_r = 0
p = 0
for cur_mid in B:
    while cur_l < len(A):
        if A[cur_l] >= cur_mid:
            break
        cur_l += 1
    while cur_r < len(C):
        if cur_mid < C[cur_r]:
            break
        cur_r += 1
    p += cur_l * (len(C) - cur_r)
print(p)

-L = [] -L.extend(((int(x), 3) for x in input().split())) -L.extend(((int(x), 2) for x in input().split())) -L.extend(((int(x), 1) for x in input().split())) -L = sorted(L, reverse=True) -cnt_C = 0 -cnt_B = 0 -cnt_A = 0 -for x, i in L: -    if i == 1: -        cnt_C += 1 -    elif i == 2: -        cnt_B += cnt_C -    elif i == 3: -        cnt_A += cnt_B -print(cnt_A) +A = sorted(map(int, input().split())) +B = sorted(map(int, input().split())) +C = sorted(map(int, input().split())) +cur_l = 0 +cur_r = 0 +p = 0 +for cur_mid in B: +    while cur_l < len(A): +        if A[cur_l] >= cur_mid: +            break +        cur_l += 1 +    while cur_r < len(C): +        if cur_mid < C[cur_r]: +            break +        cur_r += 1 +    p += cur_l * (len(C) - cur_r) +print(p)