def lma():return list(map(int, input().split()))#x or y

a = int(eval(input()))

k=[]

s=[]

c=0

s= [lma()]

x2= lma()

x3 = lma()

s.append(x2)

s.append(x3)

res =0

r =0

for j in range(3):

    for i in range(a):

        k.append([j,s[j][i]])

k.sort(key=lambda x: x[1], reverse=True)

for i in range(a*3):

    if k[i][0] == 2:

       c+=1

    elif k[i][0] == 1:

       r+=c 

    else:

       #res+=sum(co[:i])

        res+=r

print(res)
from bisect import bisect_left,bisect_right



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

ans = 0

cns = 0

for i in B:

    x = bisect_left(A,i)

    y = bisect_right(C,i)

    y = n - y

    ans += x*y

print(ans)





def lma():
    return list(map(int, input().split()))  # x or y


a = int(eval(input()))
k = []
s = []
c = 0
s = [lma()]
x2 = lma()
x3 = lma()
s.append(x2)
s.append(x3)
res = 0
r = 0
for j in range(3):
    for i in range(a):
        k.append([j, s[j][i]])
k.sort(key=lambda x: x[1], reverse=True)
for i in range(a * 3):
    if k[i][0] == 2:
        c += 1
    elif k[i][0] == 1:
        r += c
    else:
        # res+=sum(co[:i])
        res += r
print(res)

from bisect import bisect_left, bisect_right

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()
ans = 0
cns = 0
for i in B:
    x = bisect_left(A, i)
    y = bisect_right(C, i)
    y = n - y
    ans += x * y
print(ans)

-def lma(): -    return list(map(int, input().split()))  # x or y +from bisect import bisect_left, bisect_right - -a = int(eval(input())) -k = [] -s = [] -c = 0 -s = [lma()] -x2 = lma() -x3 = lma() -s.append(x2) -s.append(x3) -res = 0 -r = 0 -for j in range(3): -    for i in range(a): -        k.append([j, s[j][i]]) -k.sort(key=lambda x: x[1], reverse=True) -for i in range(a * 3): -    if k[i][0] == 2: -        c += 1 -    elif k[i][0] == 1: -        r += c -    else: -        # res+=sum(co[:i]) -        res += r -print(res) +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() +ans = 0 +cns = 0 +for i in B: +    x = bisect_left(A, i) +    y = bisect_right(C, i) +    y = n - y +    ans += x * y +print(ans)