n=int(eval(input()))

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

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

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

import bisect

a.sort()

c.sort()

cl=len(c)

cnt=0

for i in b:

    x=bisect.bisect_left(a,i)

    y=bisect.bisect_right(c,i)

    cnt+=x*(cl-y)

print(cnt)

    

n=int(eval(input()))

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

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

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

import bisect

a.sort()

b.sort()

c.sort()

ans=0

for i in range(n):

    ans+=bisect.bisect_left(a,b[i])*(n-bisect.bisect_right(c,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()))
import bisect

a.sort()
c.sort()
cl = len(c)
cnt = 0
for i in b:
    x = bisect.bisect_left(a, i)
    y = bisect.bisect_right(c, i)
    cnt += x * (cl - y)
print(cnt)

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
import bisect

a.sort()
b.sort()
c.sort()
ans = 0
for i in range(n):
    ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))
print(ans)

+b.sort() -cl = len(c) -cnt = 0 -for i in b: -    x = bisect.bisect_left(a, i) -    y = bisect.bisect_right(c, i) -    cnt += x * (cl - y) -print(cnt) +ans = 0 +for i in range(n): +    ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i])) +print(ans)