from collections import Counter n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a_3 = list(map(lambda x:x % 3,a)) b_3 = list(map(lambda x:x % 3,b)) c_3 = list(map(lambda x:x % 3,c)) a_counter = Counter(a_3) b_counter = Counter(b_3) c_counter = Counter(c_3) print((a_counter[1] + a_counter[2]) * (b_counter[1] + b_counter[2]) * (c_counter[1] + c_counter[2]))