n=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) C=list(map(int,input().split())) x,y,z=n,n,n for i in range(n): if A[i]%3==0: x-=1 for i in range(n): if B[i]%3==0: y-=1 for i in range(n): if C[i]%3==0: z-=1 print(x*y*z)