_ = input() s = 1 for i in range(3): s *= len([n for n in input().split() if int(n)%3 != 0]) print(s)