n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) def check(a): cnt = 0 for i in range(len(a)): if a[i]%3 != 0: cnt += 1 return cnt ans = check(a)*check(b)*check(c) print(ans)