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

AtoB=[0 for i in range(n)]

BtoC=[0 for i in range(n+1)]

for i in range(n):

  top=a[i]

  h=n

  l=-1

  while h-l>1:

    mid=(h+l)//2

    if b[mid]>top:

      h=mid

    else:

      l=mid

  if h==0 and top>b[0]:

    h=-1

  AtoB[i]=h #smallestB-index

for i in range(n-1,-1,-1):

  top=b[i]

  h=n

  l=-1

  while h-l>1:

    mid=(h+l)//2

    if c[mid]>top:

      h=mid

    else:

      l=mid

  BtoC[i]+=BtoC[i+1]+n-h #according to B,C patten

ans=0

for i in range(n):

  ans+=BtoC[AtoB[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()

ans=0

for i in range(n):

  middle=b[i]

  h=n

  l=-1

  while h-l>1:

    m=(h+l)//2

    if a[m]<middle:

      l=m

    else:

      h=m

  ab=l+1

  h=n

  l=-1

  while h-l>1:

    m=(h+l)//2

    if c[m]>middle:

      h=m

    else:

      l=m

  bc=n-h

  ans+=ab*bc

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()
AtoB = [0 for i in range(n)]
BtoC = [0 for i in range(n + 1)]
for i in range(n):
    top = a[i]
    h = n
    l = -1
    while h - l > 1:
        mid = (h + l) // 2
        if b[mid] > top:
            h = mid
        else:
            l = mid
    if h == 0 and top > b[0]:
        h = -1
    AtoB[i] = h  # smallestB-index
for i in range(n - 1, -1, -1):
    top = b[i]
    h = n
    l = -1
    while h - l > 1:
        mid = (h + l) // 2
        if c[mid] > top:
            h = mid
        else:
            l = mid
    BtoC[i] += BtoC[i + 1] + n - h  # according to B,C patten
ans = 0
for i in range(n):
    ans += BtoC[AtoB[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()
ans = 0
for i in range(n):
    middle = b[i]
    h = n
    l = -1
    while h - l > 1:
        m = (h + l) // 2
        if a[m] < middle:
            l = m
        else:
            h = m
    ab = l + 1
    h = n
    l = -1
    while h - l > 1:
        m = (h + l) // 2
        if c[m] > middle:
            h = m
        else:
            l = m
    bc = n - h
    ans += ab * bc
print(ans)

-AtoB = [0 for i in range(n)] -BtoC = [0 for i in range(n + 1)] +ans = 0 -    top = a[i] +    middle = b[i] -        mid = (h + l) // 2 -        if b[mid] > top: -            h = mid +        m = (h + l) // 2 +        if a[m] < middle: +            l = m -            l = mid -    if h == 0 and top > b[0]: -        h = -1 -    AtoB[i] = h  # smallestB-index -for i in range(n - 1, -1, -1): -    top = b[i] +            h = m +    ab = l + 1 -        mid = (h + l) // 2 -        if c[mid] > top: -            h = mid +        m = (h + l) // 2 +        if c[m] > middle: +            h = m -            l = mid -    BtoC[i] += BtoC[i + 1] + n - h  # according to B,C patten -ans = 0 -for i in range(n): -    ans += BtoC[AtoB[i]] +            l = m +    bc = n - h +    ans += ab * bc