N = int(input()) an = list(map(int,input().split())) bn = list(map(int,input().split())) cn = list(map(int,input().split())) an_n3 = [i for i in an if i % 3 != 0] bn_n3 = [j for j in bn if j % 3 != 0] cn_n3 = [k for k in cn if k % 3 != 0] print(len(an_n3)*len(bn_n3)*len(cn_n3))