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

count_a = sum(1 for x in a if x % 3 != 0)
count_b = sum(1 for x in b if x % 3 != 0)
count_c = sum(1 for x in c if x % 3 != 0)

print(count_a * count_b * count_c)