



N = int(input())

As = [(int(i), 2) for i in input().split(" ")]

Bs = [(int(i), 1) for i in input().split(" ")]

Cs = [(int(i), 0) for i in input().split(" ")]



l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1)



ac = 0

bc = 0

cc = 0



for i in l:

    if i[1] == 2:

        ac += 1

    elif i[1] == 1:

        bc += ac

    elif i[1] == 0:

        cc += bc

print(cc)




N = int(input())

As = [(int(i), 2) for i in input().split(" ")]

Bs = [(int(i), 1) for i in input().split(" ")]

Cs = [(int(i), 0) for i in input().split(" ")]



l = sorted(As + Bs + Cs)



ac = 0

bc = 0

cc = 0



for i in l:

    if i[1] == 2:

        ac += 1

    elif i[1] == 1:

        bc += ac

    elif i[1] == 0:

        cc += bc

print(cc)
N = int(input())
As = [(int(i), 2) for i in input().split(" ")]
Bs = [(int(i), 1) for i in input().split(" ")]
Cs = [(int(i), 0) for i in input().split(" ")]
l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1)
ac = 0
bc = 0
cc = 0
for i in l:
    if i[1] == 2:
        ac += 1
    elif i[1] == 1:
        bc += ac
    elif i[1] == 0:
        cc += bc
print(cc)

N = int(input())
As = [(int(i), 2) for i in input().split(" ")]
Bs = [(int(i), 1) for i in input().split(" ")]
Cs = [(int(i), 0) for i in input().split(" ")]
l = sorted(As + Bs + Cs)
ac = 0
bc = 0
cc = 0
for i in l:
    if i[1] == 2:
        ac += 1
    elif i[1] == 1:
        bc += ac
    elif i[1] == 0:
        cc += bc
print(cc)

-l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1) +l = sorted(As + Bs + Cs)