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 A: if i % 3 != 0: a += 1 for i in B: if i % 3 != 0: b += 1 for i in C: if i % 3 != 0: c += 1 print(a * b * c)