def f(t): cnt = 0 for x in t: if x % 3 != 0: cnt += 1 return cnt input() a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) print(f(a) * f(b) * f(c))