print((3**int(eval(input()))-2**sum(~int(s)%2 for s in input().split())))
print((3**int(eval(input()))-2**sum(int(s)%2==0for s in input().split())))
print((3 ** int(eval(input())) - 2 ** sum(~int(s) % 2 for s in input().split())))

print((3 ** int(eval(input())) - 2 ** sum(int(s) % 2 == 0 for s in input().split())))

-print((3 ** int(eval(input())) - 2 ** sum(~int(s) % 2 for s in input().split()))) +print((3 ** int(eval(input())) - 2 ** sum(int(s) % 2 == 0 for s in input().split())))