# 【考察】 # 3の倍数でない数の全組み合わせなので、単純な掛け算でOK import sequtils import strutils var T: int = stdin.readLine().parseInt() # 各配列について事前に3の約数でない数のみをfilterする var A = filter(map(stdin.readLine().split(" "), proc(x: string): int = x.parseInt()), proc(x: int): bool = x mod 3 != 0) var B = filter(map(stdin.readLine().split(" "), proc(x: string): int = x.parseInt()), proc(x: int): bool = x mod 3 != 0) var C = filter(map(stdin.readLine().split(" "), proc(x: string): int = x.parseInt()), proc(x: int): bool = x mod 3 != 0) echo(A.len() * B.len() * C.len())