n = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) a = 0 b = 0 c = 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)