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

AB = [0]*N

total = 0

for i in range(N):

  left = -1

  right = N

  while right-left>1:

    mid = left + (right-left)//2

    if A[mid]>=B[i]:

      right = mid

    else:

      left = mid

  AB[i]=right

for i in range(1,N):

  AB[i]+=AB[i-1]

for i in range(N):

  left = -1

  right = N

  while right-left>1:

    mid = left + (right-left)//2

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

      right = mid

    else:

      left = mid

  if right!=0:

    total+=AB[right-1]

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

  left = -1

  right = N

  while right-left>1:

    mid = left + (right-left)//2

    if A[mid]>=B[i]:

      right = mid

    else:

      left = mid

  left2 = -1

  right2 = N

  while right2-left2>1:

    mid2 = left2 + (right2-left2)//2

    if C[mid2]>B[i]:

      right2 = mid2

    else:

      left2 = mid2

  total+=right*(N-right2)

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()
AB = [0] * N
total = 0
for i in range(N):
    left = -1
    right = N
    while right - left > 1:
        mid = left + (right - left) // 2
        if A[mid] >= B[i]:
            right = mid
        else:
            left = mid
    AB[i] = right
for i in range(1, N):
    AB[i] += AB[i - 1]
for i in range(N):
    left = -1
    right = N
    while right - left > 1:
        mid = left + (right - left) // 2
        if B[mid] >= C[i]:
            right = mid
        else:
            left = mid
    if right != 0:
        total += AB[right - 1]
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):
    left = -1
    right = N
    while right - left > 1:
        mid = left + (right - left) // 2
        if A[mid] >= B[i]:
            right = mid
        else:
            left = mid
    left2 = -1
    right2 = N
    while right2 - left2 > 1:
        mid2 = left2 + (right2 - left2) // 2
        if C[mid2] > B[i]:
            right2 = mid2
        else:
            left2 = mid2
    total += right * (N - right2)
print(total)

-AB = [0] * N -    AB[i] = right -for i in range(1, N): -    AB[i] += AB[i - 1] -for i in range(N): -    left = -1 -    right = N -    while right - left > 1: -        mid = left + (right - left) // 2 -        if B[mid] >= C[i]: -            right = mid +    left2 = -1 +    right2 = N +    while right2 - left2 > 1: +        mid2 = left2 + (right2 - left2) // 2 +        if C[mid2] > B[i]: +            right2 = mid2 -            left = mid -    if right != 0: -        total += AB[right - 1] +            left2 = mid2 +    total += right * (N - right2)