N = int(eval(input()))

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

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

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





#A2 = sorted(A)

#B2 = sorted(B)

#C2 = sorted(C)





def numadd(up, down):

    array = []

    count = 0

    last = 0

    for i in range(0,N):

        while down[i] > up[count]:

            count = count + 1

            if count == N:

                count = count - 1

                last = 1

                break

        array.append(count + last)

    return array



B3 = numadd(sorted(A),sorted(B))

C3 = numadd(sorted(B),sorted(C))



B4 = [B3[0]]

for i in range(0,N-1):

    B4.append(B4[i] + B3[i+1])



ans = 0

for i in range (0,N):

    if C3[i] > 0:

        ans = ans + B4[C3[i]-1]



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

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

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

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





A2 = sorted(A)

B2 = sorted(B)

C2 = sorted(C)



A2.append(2000000000)

B2.append(2000000000)



def numadd(up, down):

    array = []

    count = 0

    for i in range(0,N):

        while down[i] > up[count]:

            count = count + 1

            

        array.append(count) #+ last)

    return array



B3 = numadd(A2,B2)

C3 = numadd(B2,C2)



B4 = [B3[0]]

for i in range(0,N-1):

    B4.append(B4[i] + B3[i+1])



ans = 0

for i in range (0,N):

    if C3[i] > 0:

        ans = ans + B4[C3[i]-1]



print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
# A2 = sorted(A)
# B2 = sorted(B)
# C2 = sorted(C)
def numadd(up, down):
    array = []
    count = 0
    last = 0
    for i in range(0, N):
        while down[i] > up[count]:
            count = count + 1
            if count == N:
                count = count - 1
                last = 1
                break
        array.append(count + last)
    return array


B3 = numadd(sorted(A), sorted(B))
C3 = numadd(sorted(B), sorted(C))
B4 = [B3[0]]
for i in range(0, N - 1):
    B4.append(B4[i] + B3[i + 1])
ans = 0
for i in range(0, N):
    if C3[i] > 0:
        ans = ans + B4[C3[i] - 1]
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A2 = sorted(A)
B2 = sorted(B)
C2 = sorted(C)
A2.append(2000000000)
B2.append(2000000000)


def numadd(up, down):
    array = []
    count = 0
    for i in range(0, N):
        while down[i] > up[count]:
            count = count + 1
        array.append(count)  # + last)
    return array


B3 = numadd(A2, B2)
C3 = numadd(B2, C2)
B4 = [B3[0]]
for i in range(0, N - 1):
    B4.append(B4[i] + B3[i + 1])
ans = 0
for i in range(0, N):
    if C3[i] > 0:
        ans = ans + B4[C3[i] - 1]
print(ans)

-# A2 = sorted(A) -# B2 = sorted(B) -# C2 = sorted(C) +A2 = sorted(A) +B2 = sorted(B) +C2 = sorted(C) +A2.append(2000000000) +B2.append(2000000000) + + -    last = 0 -            if count == N: -                count = count - 1 -                last = 1 -                break -        array.append(count + last) +        array.append(count)  # + last) -B3 = numadd(sorted(A), sorted(B)) -C3 = numadd(sorted(B), sorted(C)) +B3 = numadd(A2, B2) +C3 = numadd(B2, C2)