N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) cnt_a = sum(a % 3 != 0 for a in A) cnt_b = sum(b % 3 != 0 for b in B) cnt_c = sum(c % 3 != 0 for c in C) print(cnt_a * cnt_b * cnt_c)