_ = input() a = [n for n in input().split() if int(n)%3 != 0] b = [n for n in input().split() if int(n)%3 != 0] c = [n for n in input().split() if int(n)%3 != 0] print(len(a)*len(b)*len(c))