n = int(eval(input()))

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

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

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

a_ls.sort()

b_ls.sort()

c_ls.sort()



# 「-より大きい」

def isOK_1(ind, key, ls):

    if ls[ind] > key:

        return True

    else: # if ls[ind] <= key

        return False





def connect_b2c_minind(key, ls):

    ok = len(ls)

    ng = -1

    while ok - ng > 1:

        mid = ng + (ok-ng) // 2

        if isOK_1(mid, key, ls):

            ok = mid

        else:

            ng = mid

    return len(ls) - ok



def isOK_2(ind, key, ls):

    if ls[ind] < key:

        return True

    else: # if ls[ind] >= key

        return False



def connect_a2b_maxind(key, ls):

    ok = -1

    ng = len(ls)

    while ng - ok > 1:

        mid = ok + (ng - ok) // 2

        if isOK_2(mid, key, ls):

            ok = mid

        else:

            ng = mid

    return ok + 1



ans = 0

for i in range(n):

    ans += connect_a2b_maxind(b_ls[i], a_ls) * connect_b2c_minind(b_ls[i], c_ls)

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

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

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

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

for ls in [a_ls,b_ls,c_ls]:

    ls.sort()



def is_not_less_than(ls, ind, key):

    if ls[ind] >= key:

        return True

    else:

        return False



def return_min_ind_whose_value_not_less_than(ls,key):

    r = len(ls)

    l = -1

    while True:

        next_ind = (r+l) // 2

        if is_not_less_than(ls, next_ind, key):

            r = next_ind

        else:

            l = next_ind

        if r - l == 1:

            return r



def is_more_than(ls, ind, key):

    if ls[ind] > key:

        return True

    else:

        return False



def return_min_ind_whose_value_more_than(ls,key):

    r = len(ls)

    l = -1

    while True:

        next_ind = (r+l) // 2

        if is_more_than(ls, next_ind, key):

            r = next_ind

        else:

            l = next_ind

        if r - l == 1:

            return r



ans = 0

for i in range(n):

    b_c = n - return_min_ind_whose_value_more_than(c_ls, b_ls[i])

    a_b = return_min_ind_whose_value_not_less_than(a_ls, b_ls[i])

    ans += b_c*a_b

print(ans)

n = int(eval(input()))
a_ls = list(map(int, input().split()))
b_ls = list(map(int, input().split()))
c_ls = list(map(int, input().split()))
a_ls.sort()
b_ls.sort()
c_ls.sort()
# 「-より大きい」
def isOK_1(ind, key, ls):
    if ls[ind] > key:
        return True
    else:  # if ls[ind] <= key
        return False


def connect_b2c_minind(key, ls):
    ok = len(ls)
    ng = -1
    while ok - ng > 1:
        mid = ng + (ok - ng) // 2
        if isOK_1(mid, key, ls):
            ok = mid
        else:
            ng = mid
    return len(ls) - ok


def isOK_2(ind, key, ls):
    if ls[ind] < key:
        return True
    else:  # if ls[ind] >= key
        return False


def connect_a2b_maxind(key, ls):
    ok = -1
    ng = len(ls)
    while ng - ok > 1:
        mid = ok + (ng - ok) // 2
        if isOK_2(mid, key, ls):
            ok = mid
        else:
            ng = mid
    return ok + 1


ans = 0
for i in range(n):
    ans += connect_a2b_maxind(b_ls[i], a_ls) * connect_b2c_minind(b_ls[i], c_ls)
print(ans)

n = int(eval(input()))
a_ls = list(map(int, input().split()))
b_ls = list(map(int, input().split()))
c_ls = list(map(int, input().split()))
for ls in [a_ls, b_ls, c_ls]:
    ls.sort()


def is_not_less_than(ls, ind, key):
    if ls[ind] >= key:
        return True
    else:
        return False


def return_min_ind_whose_value_not_less_than(ls, key):
    r = len(ls)
    l = -1
    while True:
        next_ind = (r + l) // 2
        if is_not_less_than(ls, next_ind, key):
            r = next_ind
        else:
            l = next_ind
        if r - l == 1:
            return r


def is_more_than(ls, ind, key):
    if ls[ind] > key:
        return True
    else:
        return False


def return_min_ind_whose_value_more_than(ls, key):
    r = len(ls)
    l = -1
    while True:
        next_ind = (r + l) // 2
        if is_more_than(ls, next_ind, key):
            r = next_ind
        else:
            l = next_ind
        if r - l == 1:
            return r


ans = 0
for i in range(n):
    b_c = n - return_min_ind_whose_value_more_than(c_ls, b_ls[i])
    a_b = return_min_ind_whose_value_not_less_than(a_ls, b_ls[i])
    ans += b_c * a_b
print(ans)

-a_ls.sort() -b_ls.sort() -c_ls.sort() -# 「-より大きい」 -def isOK_1(ind, key, ls): -    if ls[ind] > key: +for ls in [a_ls, b_ls, c_ls]: +    ls.sort() + + +def is_not_less_than(ls, ind, key): +    if ls[ind] >= key: -    else:  # if ls[ind] <= key +    else: -def connect_b2c_minind(key, ls): -    ok = len(ls) -    ng = -1 -    while ok - ng > 1: -        mid = ng + (ok - ng) // 2 -        if isOK_1(mid, key, ls): -            ok = mid +def return_min_ind_whose_value_not_less_than(ls, key): +    r = len(ls) +    l = -1 +    while True: +        next_ind = (r + l) // 2 +        if is_not_less_than(ls, next_ind, key): +            r = next_ind -            ng = mid -    return len(ls) - ok +            l = next_ind +        if r - l == 1: +            return r -def isOK_2(ind, key, ls): -    if ls[ind] < key: +def is_more_than(ls, ind, key): +    if ls[ind] > key: -    else:  # if ls[ind] >= key +    else: -def connect_a2b_maxind(key, ls): -    ok = -1 -    ng = len(ls) -    while ng - ok > 1: -        mid = ok + (ng - ok) // 2 -        if isOK_2(mid, key, ls): -            ok = mid +def return_min_ind_whose_value_more_than(ls, key): +    r = len(ls) +    l = -1 +    while True: +        next_ind = (r + l) // 2 +        if is_more_than(ls, next_ind, key): +            r = next_ind -            ng = mid -    return ok + 1 +            l = next_ind +        if r - l == 1: +            return r -    ans += connect_a2b_maxind(b_ls[i], a_ls) * connect_b2c_minind(b_ls[i], c_ls) +    b_c = n - return_min_ind_whose_value_more_than(c_ls, b_ls[i]) +    a_b = return_min_ind_whose_value_not_less_than(a_ls, b_ls[i]) +    ans += b_c * a_b