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



total = 0



for i in range(N):

    low1 = 0

    high = N

    while low1 < high:

        mid = (low1 + high) // 2

        if A[mid] < B[i]:

            low1 = mid + 1

        else:

            high = mid

    low2 = 0

    high = N

    while low2 < high:

        mid = (low2 + high) // 2

        if C[mid] <= B[i]:

            low2 = mid + 1

        else:

            high = mid

    total += low1 * (N - low2)



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

A = sorted([int(i) for i in input().split()])

B = [int(i) for i in input().split()]

C = sorted([int(i)-1 for i in input().split()])



def bis(x,y):

    low = 0

    high = N

    while low < high:

        mid = (low + high) // 2

        if x[mid] < y:

            low = mid + 1

        else:

            high = mid

    return low



total = 0

for b in B:

    total += bis(A,b) * (N - bis(C,b))



print(total)

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()
total = 0
for i in range(N):
    low1 = 0
    high = N
    while low1 < high:
        mid = (low1 + high) // 2
        if A[mid] < B[i]:
            low1 = mid + 1
        else:
            high = mid
    low2 = 0
    high = N
    while low2 < high:
        mid = (low2 + high) // 2
        if C[mid] <= B[i]:
            low2 = mid + 1
        else:
            high = mid
    total += low1 * (N - low2)
print(total)

N = int(eval(input()))
A = sorted([int(i) for i in input().split()])
B = [int(i) for i in input().split()]
C = sorted([int(i) - 1 for i in input().split()])


def bis(x, y):
    low = 0
    high = N
    while low < high:
        mid = (low + high) // 2
        if x[mid] < y:
            low = mid + 1
        else:
            high = mid
    return low


total = 0
for b in B:
    total += bis(A, b) * (N - bis(C, b))
print(total)

-A = list(map(int, input().split())) -B = list(map(int, input().split())) -C = list(map(int, input().split())) -A.sort() -B.sort() -C.sort() -total = 0 -for i in range(N): -    low1 = 0 +A = sorted([int(i) for i in input().split()]) +B = [int(i) for i in input().split()] +C = sorted([int(i) - 1 for i in input().split()]) + + +def bis(x, y): +    low = 0 -    while low1 < high: -        mid = (low1 + high) // 2 -        if A[mid] < B[i]: -            low1 = mid + 1 +    while low < high: +        mid = (low + high) // 2 +        if x[mid] < y: +            low = mid + 1 -    low2 = 0 -    high = N -    while low2 < high: -        mid = (low2 + high) // 2 -        if C[mid] <= B[i]: -            low2 = mid + 1 -        else: -            high = mid -    total += low1 * (N - low2) +    return low + + +total = 0 +for b in B: +    total += bis(A, b) * (N - bis(C, b))