n = int(eval(input()))

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

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

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

t = 0

ans = 0

u =[0]*n

d =[0]*n

a2 =[]

b2 =[]

c2 =[]



for i in range(n):

    a2.append([2,a[i]])

for i in range(n):

    b2.append([1,b[i]])

for i in range(n):

    c2.append([0,c[i]])

a2b2=a2+b2

b2c2=b2+c2



a2b2.sort(key = lambda x:(x[1],x[0]))

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



j=0

c=0

for i in range(2*n):

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

        c+=1

    if a2b2[i][0]==1:

        u[j]=c

        j+=1

j=0

c=0

for i in range(2*n):

    if b2c2[i][0]==0:

        c+=1

    if b2c2[i][0]==1:

        d[j]=c

        j+=1

d.reverse()

for i in range(n):

    ans+=u[i]*d[i]

print(ans)

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



def n_smaller_a(num):

    if num>a[n-1]:

        return n

    if num<=a[0]:

        return 0

    left=0

    right=n-1

    mid=(left+right)//2

    while right-left>1:

        if a[mid]>=num:

            right=mid

        else:

            left=mid

        mid=(left+right)//2



    if a[left]==num:

        return left

    else:

        return left+1



def n_bigger_c(num):

    if num >= c[n-1]:

        return 0

    if num < c[0]:

        return n

    left=0

    right=n-1

    mid=(left+right)//2

    while right-left>1:

        if c[mid]>num:

            right=mid

        else:

            left=mid

        mid=(left+right)//2

    if c[right]==num:

        return n-right-1

    else:

        return n-right



ans = 0



for i in range(n):

    ans+=n_bigger_c(b[i])*n_smaller_a(b[i])

print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
t = 0
ans = 0
u = [0] * n
d = [0] * n
a2 = []
b2 = []
c2 = []
for i in range(n):
    a2.append([2, a[i]])
for i in range(n):
    b2.append([1, b[i]])
for i in range(n):
    c2.append([0, c[i]])
a2b2 = a2 + b2
b2c2 = b2 + c2
a2b2.sort(key=lambda x: (x[1], x[0]))
b2c2.sort(key=lambda x: (x[1], x[0]), reverse=True)
j = 0
c = 0
for i in range(2 * n):
    if a2b2[i][0] == 2:
        c += 1
    if a2b2[i][0] == 1:
        u[j] = c
        j += 1
j = 0
c = 0
for i in range(2 * n):
    if b2c2[i][0] == 0:
        c += 1
    if b2c2[i][0] == 1:
        d[j] = c
        j += 1
d.reverse()
for i in range(n):
    ans += u[i] * d[i]
print(ans)

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


def n_smaller_a(num):
    if num > a[n - 1]:
        return n
    if num <= a[0]:
        return 0
    left = 0
    right = n - 1
    mid = (left + right) // 2
    while right - left > 1:
        if a[mid] >= num:
            right = mid
        else:
            left = mid
        mid = (left + right) // 2
    if a[left] == num:
        return left
    else:
        return left + 1


def n_bigger_c(num):
    if num >= c[n - 1]:
        return 0
    if num < c[0]:
        return n
    left = 0
    right = n - 1
    mid = (left + right) // 2
    while right - left > 1:
        if c[mid] > num:
            right = mid
        else:
            left = mid
        mid = (left + right) // 2
    if c[right] == num:
        return n - right - 1
    else:
        return n - right


ans = 0
for i in range(n):
    ans += n_bigger_c(b[i]) * n_smaller_a(b[i])
print(ans)

-t = 0 +a.sort() +b.sort() +c.sort() + + +def n_smaller_a(num): +    if num > a[n - 1]: +        return n +    if num <= a[0]: +        return 0 +    left = 0 +    right = n - 1 +    mid = (left + right) // 2 +    while right - left > 1: +        if a[mid] >= num: +            right = mid +        else: +            left = mid +        mid = (left + right) // 2 +    if a[left] == num: +        return left +    else: +        return left + 1 + + +def n_bigger_c(num): +    if num >= c[n - 1]: +        return 0 +    if num < c[0]: +        return n +    left = 0 +    right = n - 1 +    mid = (left + right) // 2 +    while right - left > 1: +        if c[mid] > num: +            right = mid +        else: +            left = mid +        mid = (left + right) // 2 +    if c[right] == num: +        return n - right - 1 +    else: +        return n - right + + -u = [0] * n -d = [0] * n -a2 = [] -b2 = [] -c2 = [] -    a2.append([2, a[i]]) -for i in range(n): -    b2.append([1, b[i]]) -for i in range(n): -    c2.append([0, c[i]]) -a2b2 = a2 + b2 -b2c2 = b2 + c2 -a2b2.sort(key=lambda x: (x[1], x[0])) -b2c2.sort(key=lambda x: (x[1], x[0]), reverse=True) -j = 0 -c = 0 -for i in range(2 * n): -    if a2b2[i][0] == 2: -        c += 1 -    if a2b2[i][0] == 1: -        u[j] = c -        j += 1 -j = 0 -c = 0 -for i in range(2 * n): -    if b2c2[i][0] == 0: -        c += 1 -    if b2c2[i][0] == 1: -        d[j] = c -        j += 1 -d.reverse() -for i in range(n): -    ans += u[i] * d[i] +    ans += n_bigger_c(b[i]) * n_smaller_a(b[i])