from collections import defaultdict import sys readline=sys.stdin.readline write=sys.stdout.write import itertools N=int(readline()) A=list(map(int,readline().split())) B=list(map(int,readline().split())) C=list(map(int,readline().split())) ans=sum(1 for a in A if a%3)*sum(1 for b in B if b%3)*sum(1 for c in C if c%3) print(ans)