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 for i in range(N): a+=A[i]%3>0 b+=B[i]%3>0 c+=C[i]%3>0 print(a*b*c)