N = int(eval(input()))

A = list(map(int,input().split()))



odd_count = 1



for a in A:

  if a%2 != 0:

    odd_count *= 1

  else:

    odd_count *= 2



print((3**N - odd_count))
N = int(eval(input()))

A = list(map(int,input().split()))



odd_count = 1



for a in A:

  if a%2 == 0:

    odd_count *= 2



print((3**N - odd_count))
N = int(eval(input()))
A = list(map(int, input().split()))
odd_count = 1
for a in A:
    if a % 2 != 0:
        odd_count *= 1
    else:
        odd_count *= 2
print((3**N - odd_count))

N = int(eval(input()))
A = list(map(int, input().split()))
odd_count = 1
for a in A:
    if a % 2 == 0:
        odd_count *= 2
print((3**N - odd_count))

-    if a % 2 != 0: -        odd_count *= 1 -    else: +    if a % 2 == 0: