n=int(eval(input()))

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

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

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

a=[0]+sorted(a)+[float('inf')]

c=[0]+sorted(c)+[float('inf')]





def bin_search_a(a,b):

    low=0

    high=len(a)-1

    while low<=high:

        mid=(low+high)//2

        if a[mid] < b <= a[mid+1]:

            return mid

        if a[mid] >= b:

            high=mid-1

        else:

            low=mid+1

    

def bin_search_c(c,b):

    low=0

    high=len(c)-1

    while low<=high:

        mid=(low+high)//2

        if c[mid] <= b < c[mid+1]:

            return mid

        if c[mid] > b:

            high=mid-1

        else:

            low=mid+1



altar=0



for bi in b:

    s=bin_search_a(a,bi)*(n-bin_search_c(c,bi))

    altar+=s

print(altar)
n=int(eval(input()))

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

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

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

a=[0]+sorted(a)+[float('inf')]

c=[0]+sorted(c)+[float('inf')]





def meguru_a(bi):

    ng=n+1 ; ok=0

    while (abs(ok - ng) > 1): 

        mid = (ok + ng) // 2

        if a[mid] < bi :

            ok = mid

        else:

            ng = mid

    return ok



def meguru_c(bi):

    ng=-1 ; ok=n

    while (abs(ok - ng) > 1):

        mid = (ok + ng) // 2

        if bi < c[mid+1]:

            ok = mid

        else:

            ng = mid

    return ok



altar=0



for bi in b:

    s=meguru_a(bi)*(n - meguru_c(bi))

    altar+=s

print(altar)
n = int(eval(input()))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))
a = [0] + sorted(a) + [float("inf")]
c = [0] + sorted(c) + [float("inf")]


def bin_search_a(a, b):
    low = 0
    high = len(a) - 1
    while low <= high:
        mid = (low + high) // 2
        if a[mid] < b <= a[mid + 1]:
            return mid
        if a[mid] >= b:
            high = mid - 1
        else:
            low = mid + 1


def bin_search_c(c, b):
    low = 0
    high = len(c) - 1
    while low <= high:
        mid = (low + high) // 2
        if c[mid] <= b < c[mid + 1]:
            return mid
        if c[mid] > b:
            high = mid - 1
        else:
            low = mid + 1


altar = 0
for bi in b:
    s = bin_search_a(a, bi) * (n - bin_search_c(c, bi))
    altar += s
print(altar)

n = int(eval(input()))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))
a = [0] + sorted(a) + [float("inf")]
c = [0] + sorted(c) + [float("inf")]


def meguru_a(bi):
    ng = n + 1
    ok = 0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if a[mid] < bi:
            ok = mid
        else:
            ng = mid
    return ok


def meguru_c(bi):
    ng = -1
    ok = n
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if bi < c[mid + 1]:
            ok = mid
        else:
            ng = mid
    return ok


altar = 0
for bi in b:
    s = meguru_a(bi) * (n - meguru_c(bi))
    altar += s
print(altar)

-def bin_search_a(a, b): -    low = 0 -    high = len(a) - 1 -    while low <= high: -        mid = (low + high) // 2 -        if a[mid] < b <= a[mid + 1]: -            return mid -        if a[mid] >= b: -            high = mid - 1 +def meguru_a(bi): +    ng = n + 1 +    ok = 0 +    while abs(ok - ng) > 1: +        mid = (ok + ng) // 2 +        if a[mid] < bi: +            ok = mid -            low = mid + 1 +            ng = mid +    return ok -def bin_search_c(c, b): -    low = 0 -    high = len(c) - 1 -    while low <= high: -        mid = (low + high) // 2 -        if c[mid] <= b < c[mid + 1]: -            return mid -        if c[mid] > b: -            high = mid - 1 +def meguru_c(bi): +    ng = -1 +    ok = n +    while abs(ok - ng) > 1: +        mid = (ok + ng) // 2 +        if bi < c[mid + 1]: +            ok = mid -            low = mid + 1 +            ng = mid +    return ok -    s = bin_search_a(a, bi) * (n - bin_search_c(c, bi)) +    s = meguru_a(bi) * (n - meguru_c(bi))