from itertools import filterfalse def is_divided_by_3(num: int) -> bool: return num % 3 == 0 def main(): N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A = list(filterfalse(is_divided_by_3, A)) B = list(filterfalse(is_divided_by_3, B)) C = list(filterfalse(is_divided_by_3, C)) print(len(A)*len(B)*len(C)) if __name__ == "__main__": main()