N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) a, b, c = 0, 0, 0 for i in range(N): if A[i] % 3 != 0: a += 1 for i in range(N): if B[i] % 3 != 0: b += 1 for i in range(N): if C[i] % 3 != 0: c += 1 print(a * b * c)