N = int(eval(input()))

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

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

C = [int(x) for x in input().split()]



A.sort()

B.sort()

C.sort()



ans = 0



for i in B:

    OK = -1

    NG = N

    while NG - OK > 1:

        mid = (OK + NG) // 2

        if A[mid] < i:

            OK = mid

        else:

            NG = mid

    countA = OK + 1

    

    OK = N

    NG = -1

    while OK - NG > 1:

        mid = (OK + NG) // 2

        if C[mid] > i:

            OK = mid

        else:

            NG = mid

    countC = N - NG - 1

    ans += countA * countC



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

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

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

C = [int(x) for x in input().split()]



A.sort()

C.sort()



ans = 0



def bisect(array, threshold, equal=False):

    OK = -1

    NG = N

    while NG - OK > 1:

        mid = (OK + NG) // 2

        if array[mid] < threshold:

            OK = mid

        elif equal == True and array[mid] == threshold:

            OK = mid

        else:

            NG = mid

    return OK + 1



for i in B:

    ans += bisect(A, i) * (N - bisect(C, i, True))



print(ans)
N = int(eval(input()))
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A.sort()
B.sort()
C.sort()
ans = 0
for i in B:
    OK = -1
    NG = N
    while NG - OK > 1:
        mid = (OK + NG) // 2
        if A[mid] < i:
            OK = mid
        else:
            NG = mid
    countA = OK + 1
    OK = N
    NG = -1
    while OK - NG > 1:
        mid = (OK + NG) // 2
        if C[mid] > i:
            OK = mid
        else:
            NG = mid
    countC = N - NG - 1
    ans += countA * countC
print(ans)

N = int(eval(input()))
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A.sort()
C.sort()
ans = 0


def bisect(array, threshold, equal=False):
    OK = -1
    NG = N
    while NG - OK > 1:
        mid = (OK + NG) // 2
        if array[mid] < threshold:
            OK = mid
        elif equal == True and array[mid] == threshold:
            OK = mid
        else:
            NG = mid
    return OK + 1


for i in B:
    ans += bisect(A, i) * (N - bisect(C, i, True))
print(ans)

-B.sort() -for i in B: + + +def bisect(array, threshold, equal=False): -        if A[mid] < i: +        if array[mid] < threshold: +            OK = mid +        elif equal == True and array[mid] == threshold: -    countA = OK + 1 -    OK = N -    NG = -1 -    while OK - NG > 1: -        mid = (OK + NG) // 2 -        if C[mid] > i: -            OK = mid -        else: -            NG = mid -    countC = N - NG - 1 -    ans += countA * countC +    return OK + 1 + + +for i in B: +    ans += bisect(A, i) * (N - bisect(C, i, True))