N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) def cnt(x): ret = 0 for i in x: if i % 3 != 0: ret += 1 return ret print (cnt(A) * cnt(B) * cnt(C))