import math for n in map(int,input().split()) : print(math.prod([sum([(1 if a % 3 != 0 else 0) for a in map(int,input().split())]) for t in range(3)]))