n = int(input())

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

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

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

al.sort()

bl.sort()

cl.sort()

l = [(0,0) for _ in range(n)]

p = 0

for i, b in enumerate(bl):

    while p < n and cl[p] <= b:

        p += 1

    l[i] = (b, n-p)

p = n-1

s = 0

t = 0

for a in al[::-1]:

    while p >= 0 and l[p][0] > a:

        s += l[p][1]

        p -= 1

    t += s

print(t)

n = int(input())

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

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

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

al.sort()

bl.sort()

cl.sort()

ap = 0

cp = 0

t = 0

for b in bl:

    while ap < n and al[ap] < b:

        ap += 1

    while cp < n and cl[cp] <= b:

        cp += 1

    t += ap * (n - cp)

print(t)

n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
bl.sort()
cl.sort()
l = [(0, 0) for _ in range(n)]
p = 0
for i, b in enumerate(bl):
    while p < n and cl[p] <= b:
        p += 1
    l[i] = (b, n - p)
p = n - 1
s = 0
t = 0
for a in al[::-1]:
    while p >= 0 and l[p][0] > a:
        s += l[p][1]
        p -= 1
    t += s
print(t)

n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
bl.sort()
cl.sort()
ap = 0
cp = 0
t = 0
for b in bl:
    while ap < n and al[ap] < b:
        ap += 1
    while cp < n and cl[cp] <= b:
        cp += 1
    t += ap * (n - cp)
print(t)

-l = [(0, 0) for _ in range(n)] -p = 0 -for i, b in enumerate(bl): -    while p < n and cl[p] <= b: -        p += 1 -    l[i] = (b, n - p) -p = n - 1 -s = 0 +ap = 0 +cp = 0 -for a in al[::-1]: -    while p >= 0 and l[p][0] > a: -        s += l[p][1] -        p -= 1 -    t += s +for b in bl: +    while ap < n and al[ap] < b: +        ap += 1 +    while cp < n and cl[cp] <= b: +        cp += 1 +    t += ap * (n - cp)