#!/usr/bin/env python3 def main(): N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) la, lb, lc = 0, 0, 0 for aa, bb, cc in zip(A, B, C): if aa % 3 != 0: la += 1 if bb % 3 != 0: lb += 1 if cc % 3 != 0: lc += 1 print(la * lb * lc) return if __name__ == '__main__': main()