N = int(eval(input()))

A = [int(a)-1 for a in eval(input())]



r = 1 if 1 in A else 2



def parity_of_nCk(n, k):

    return (n&k)==k



ans = 0

for i, a in enumerate(A):

    if a & r:

        if parity_of_nCk(N-1,i):

            ans ^= 1



print((ans*r))
N=int(eval(input()))

A=[int(a)-1 for a in eval(input())]

r=1 if 1 in A else 2

print((sum([1 if A[i]&r and (N-1&i)==i else 0 for i in range(N)])%2*r))
N = int(eval(input()))
A = [int(a) - 1 for a in eval(input())]
r = 1 if 1 in A else 2


def parity_of_nCk(n, k):
    return (n & k) == k


ans = 0
for i, a in enumerate(A):
    if a & r:
        if parity_of_nCk(N - 1, i):
            ans ^= 1
print((ans * r))

N = int(eval(input()))
A = [int(a) - 1 for a in eval(input())]
r = 1 if 1 in A else 2
print((sum([1 if A[i] & r and (N - 1 & i) == i else 0 for i in range(N)]) % 2 * r))

- - -def parity_of_nCk(n, k): -    return (n & k) == k - - -ans = 0 -for i, a in enumerate(A): -    if a & r: -        if parity_of_nCk(N - 1, i): -            ans ^= 1 -print((ans * r)) +print((sum([1 if A[i] & r and (N - 1 & i) == i else 0 for i in range(N)]) % 2 * r))