Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex.

Initially there are k cycles, i-th of them consisting of exactly v_{i} vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!).

Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with a_{i} vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? 

Peter is pretty good at math, but now he asks you to help.


-----Input-----

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make.

The second line contains n space separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9), i-th of them stands for the number of vertices in the cycle added before the i-th test.


-----Output-----

Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise.


-----Examples-----
Input
3
1 2 3

Output
2
1
1

Input
5
1 1 5 1 1

Output
2
2
2
2
2



-----Note-----

In the first sample test:

In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses.

In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses.

In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins.

In the second sample test:

Having cycles of size 1 is like not having them (because no one can make a move on them). 

In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3.

  If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses.  If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. 

So, either way first player loses.

Difficulty: EASY
Tags: Game theory

Mathematics

Starter code:

Solutions:
I = lambda : list(map(int, input().split()))
n = int(input())
b = I()
ans = 2
for i in b:
	if i % 2 == 0:
		ans = 3 - ans
	print(ans)


from itertools import accumulate
n = int(input())
a = list(map(int, input().split(' ')))
b = list(accumulate((~a[i] & 1 for i in range(n)), lambda i, j: i ^ j))
for i in b:
	print('2' if i == 0 else '1')


n = int(input())
l = list(map(int, input().split()))
last = 2
for i in l:
	if i == 1:
		print(last)
	elif i % 2 == 1:
		print(last)
	else:
		last = 2 if last == 1 else 1
		print(last)


input()
res = 1
for a in map(int, input().split()):
	res ^= (a - 1) % 2
	print(res + 1)


n = int(input())
arr = list(map(int, input().split()))
ans = []
sm = 0
p = 'f1'
for i in range(n):
	sm += arr[i] - 1
	if sm % 2 == 0:
		ans.append(2)
	else:
		ans.append(1)
for i in ans:
	print(i)


n = int(input())
a = [int(x) % 2 for x in input().split()]
ans = ''
even = 0
for i in range(n):
	if a[i] == 0:
		even += 1
	if even % 2:
		ans += '1\n'
	else:
		ans += '2\n'
print(ans)


n = int(input())
a = list(map(int, input().split(' ')))
arr = []
for i in range(n):
	if i == 0:
		if (a[i] - 1) % 2 == 0:
			arr.append(2)
		else:
			arr.append(1)
	elif (a[i] - 1) % 2 == 0:
		arr.append(arr[-1])
	elif arr[-1] == 1:
		arr.append(2)
	else:
		arr.append(1)
	print(arr[i])


n = int(input())
a = list(map(int, input().split()))
cur = 0
for i in a:
	cur += i - 1
	print(1 if cur % 2 else 2)


import os
import sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7

def main():
	n = int(input())
	l = list(map(int, input().split()))
	winner = 2
	for i in range(n):
		item = l[i]
		if item < 2:
			print(winner)
			continue
		if item % 2 == 1:
			print(winner)
		elif winner == 1:
			print(2)
			winner = 2
		else:
			print(1)
			winner = 1
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


n = int(input())
a = list(map(int, input().split()))
(odd, even) = (0, 0)
for i in range(n):
	if a[i] & 1 and a[i] > 1:
		odd += 1
	elif not a[i] & 1 and a[i] > 1:
		even += 1
	if even & 1:
		print('1')
	else:
		print('2')


n = int(input())
m = list(map(int, input().split()))
from itertools import accumulate
ac = list(accumulate(m))
sol = []
for (i, e) in enumerate(ac):
	if (e - (i + 1)) % 2 == 0:
		sol.append(2)
	else:
		sol.append(1)
print(*sol, sep='\n')


n = int(input())
prev = 0
for i in [int(j) for j in input().split()]:
	if prev == 0:
		if i == 1:
			print(2)
			prev = 2
		else:
			prev = i % 2 + 1
			print(prev)
	elif i == 1:
		print(prev)
	else:
		box = i % 2
		if prev == 1:
			prev = (box + 1) % 2 + 1
			print(prev)
		else:
			prev = box + 1
			print(prev)


(n, v) = (int(input()), 0)
for i in map(int, input().split()):
	v ^= i - 1
	print(1 if v & 1 else 2)


n = int(input())
l = [int(i) for i in input().split()]
temp = 0
for i in l:
	temp += i - 1
	if temp % 2 == 0:
		print(2)
	else:
		print(1)


def main():
	n = int(input())
	items = input().split(' ')
	s = 0
	for p in items:
		s += int(p) + 1
		print(2 - (s & 1))
main()


import sys
fin = sys.stdin
fout = sys.stdout
n = int(fin.readline())
a = list(map(int, fin.readline().split()))
res = []
curN = 2
for cur in a:
	if cur % 2 == 0:
		curN = 3 - curN
	res.append(curN)
fout.write('\n'.join(map(str, res)))


user = int(input())
a = map(int, input().split(' '))
x = 2
for i in a:
	if i & 1 == 0:
		x = 3 - x
	print(x)


n = input()
a = list(input().strip().split())[:int(n)]
ev = 2
for i in a:
	l = len(i)
	if int(i[l - 1]) == 2 or int(i[l - 1]) == 0 or int(i[l - 1]) == 4 or (int(i[l - 1]) == 6) or (int(i[l - 1]) == 8):
		ev += 1
		if ev > 2:
			ev = ev - 2
	print(ev)


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
n = int(I1())
a = list(I())
li = [0] * (n + 1)
for i in range(n):
	li[i + 1] = li[i] + a[i] - 1
for i in range(1, n + 1):
	print(1 if li[i] % 2 != 0 else 2)


n = int(input())
a = list(map(int, input().split()))
b = 2
for i in a:
	if i % 2 == 0:
		b = 3 - b
	print(b)


(n, s) = (int(input()), 0)
a = list(map(int, input().split()))
for i in range(n):
	if a[i] != 1:
		s += a[i] - 1
	print(1 if s % 2 else 2)


numTests = int(input())
allCycles = tuple((int(x) for x in input().split()))
cuts = 0
for i in range(numTests):
	cuts += allCycles[i] - 1
	print(2 if cuts % 2 == 0 else 1)


n = input()
al = list(map(int, input().split()))
s = 0
for i in al:
	s += i - 1
	print([1, 2][(s - 1) % 2])


n = int(input())
c = list(map(int, input().split()))
x = 0
y = 0
for v in c:
	if v != 1:
		x += v
		y += 1
	if x == 0:
		print(2)
	elif (x - y) % 2 == 0:
		print(2)
	else:
		print(1)


n = int(input(''))
t_as = input('')
arr = t_as.split(' ')
counter = 0
my_list = []
sumup = 0
while counter < len(arr):
	s = int(arr[counter]) - 1
	sumup = s + sumup
	if sumup % 2 == 0:
		print('2')
	else:
		print('1')
	counter = counter + 1


n = int(input())
ri = lambda : map(int, input().split(' '))
a = list(ri())
game = 0
for x in a:
	game += x - 1
	if game % 2 == 1:
		print(1)
	else:
		print(2)


n = int(input())
arr = list(map(int, input().split()))
res = []
c = 0
for i in arr:
	c += i - 1
	res.append([2, 1][c % 2])
print('\n'.join(map(str, res)))


N = int(input())
K = list(map(int, input().split()))
su = 0
for k in K:
	k -= 1
	su += k
	print(2 if su % 2 == 0 else 1)


n = int(input())
arr = [int(x) for x in input().split()]
even = 0
for num in arr:
	if num % 2 == 0:
		even += 1
	if even % 2 == 0:
		print(2)
	else:
		print(1)


n = int(input())
a = [int(x) for x in input().split()]
m = 2
w = 1
for i in a:
	if i % 2 == 0:
		print(w)
		t = m
		m = w
		w = t
	else:
		print(m)


n = int(input())
numbers = list(map(int, input().split(' ')))
sum = 0
for i in range(n):
	sum += numbers[i] - 1
	print(1 if sum % 2 else 2)


n = int(input())
a = input().strip().split()
for (index, item) in enumerate(a):
	a[index] = int(item)
ou = 0
for i in range(n):
	if a[i] % 2 == 0:
		ou += 1
	if ou % 2 == 0:
		print(2)
	else:
		print(1)


N = int(input())
X = list(map(int, input().split()))
(SUM, Ans) = (0, [])
for i in range(N):
	SUM += X[i] - 1
	Ans.append('1' if SUM % 2 == 1 else '2')
print('\n'.join(Ans))


n = int(input())
arr = [int(i) for i in input().split()]
count = 0
res = []
for i in arr:
	if i % 2 == 0:
		count += 1
	if count % 2 == 1:
		res.append(1)
	else:
		res.append(2)
for i in res:
	print(i)


n = int(input())
a = list(map(int, input().split()))
l = []
play = 1
for i in range(n):
	if a[i] == 1:
		if play == 1:
			print(2)
		else:
			print(1)
			play = 2
	elif a[i] % 2 == 0:
		if play == 1:
			print(1)
			play = 2
		else:
			print(2)
			play = 1
	elif play == 1:
		print(2)
		play = 1
	else:
		print(1)
		play = 2


n = int(input())
l = list(map(int, input().split()))
turn = 1
for i in l:
	if turn == 1:
		if i % 2 == 0:
			print(1)
			turn = 2
		else:
			print(2)
			turn = 1
	elif i % 2 == 0:
		print(2)
		turn = 1
	else:
		print(1)
		turn = 2


n = int(input())
L = list(map(int, input().split()))
sm = 0
for i in range(n):
	sm += L[i]
	if (sm - i - 1) % 2 == 0:
		print(2)
	else:
		print(1)


def main():
	n = int(input())
	t = list(map(int, input().split()))
	somme = 0
	for i in range(len(t)):
		somme += t[i] - 1
		if somme % 2 == 0:
			print(2)
		else:
			print(1)
main()


a = int(input())
x = list(map(int, input().split()))
last = 0
for i in range(a):
	last += x[i] - 1
	if last % 2:
		print(1)
	else:
		print(2)


input()
p = 2
for a in map(int, input().split()):
	p = (3 - p, p)[a % 2]
	print(p)


n = int(input())
a = list(map(int, input().split()))
q = 1
for i in range(n):
	if a[i] % 2 == 1:
		print(q + 1)
	else:
		q = (q + 1) % 2
		print(q + 1)


num = int(input())
first = True
n = True
nums = list(map(int, input().split()))
for i in range(num):
	cur = nums[i] % 2 == 0
	if first:
		n = cur
		first = False
	elif n and cur or (not n and (not cur)):
		n = False
	else:
		n = True
	if n:
		print(1)
	else:
		print(2)


n = int(input())
a = [int(x) for x in input().split()]
s = 0
for i in range(n):
	s += a[i] - 1
	if s % 2 == 0:
		print(2)
	else:
		print(1)


try:
	N = int(input())
	for i in range(N):
		sum = 0
		t = input().split()
		for item in t:
			sum += int(item) - 1
			if sum % 2 == 0:
				print(2)
			else:
				print(1)
except EOFError as e:
	print(end='')


n = int(input())
import sys
b = [2, 1]
a = list(map(int, sys.stdin.readline().split()))
ans = 0
for i in a:
	ans += i - 1
	print(b[ans % 2])


n = int(input())
l = list(map(lambda x: int(x) - 1, input().split()))
s = 0
for i in l:
	s += i
	s %= 2
	print(s + (not s) * 2)


n = int(input())
vals = list(map(int, input().split()))
need_seps = 0
for i in range(n):
	v = vals[i]
	need_seps += v - 1
	if need_seps % 2:
		print(1)
	else:
		print(2)


lst = [1, 2]
idx = 0
n = input()
lose = 1
for i in input().split():
	i = int(i)
	if (i - 1) % 2 == 0:
		idx = (1 + idx) % 2
	print(lst[idx])
	idx = (1 + idx) % 2


n = int(input())
a = list(map(int, input().split()))
odd = 0
even = 0
turn = 0
for i in range(n):
	if a[i] % 2 == 0:
		even += 1
	if even % 2 != 0:
		print(1)
	else:
		print(2)


x = int(input())
sun = 0
xx = input()
a = [int(n) for n in xx.split()]
for i in a:
	sun += i - 1
	if sun % 2:
		print(1)
	else:
		print(2)


(n, s) = (input(), 1)
for val in map(lambda x: int(x) - 1, input().split()):
	s ^= val & 1
	print(s + 1)


from collections import deque
import math
n = int(input())
array = input().split()
for i in range(n):
	array[i] = int(array[i])
j = 0
for i in range(n):
	if array[i] != 1:
		break
	else:
		print(2)
		j += 1
nextStep = 1
for i in range(j, n):
	if array[i] % 2 == 0:
		if nextStep == 1:
			print(1)
			nextStep = 2
		else:
			print(2)
			nextStep = 1
	elif nextStep == 1:
		print(2)
	else:
		print(1)


n = int(input())
data = list(map(int, input().split()))
for i in range(n):
	data[i] -= 1
winner = data[0] % 2
print(2 - winner)
for i in range(1, n):
	if data[i] % 2 == 1:
		winner ^= 1
	print(2 - winner)


a = int(input())
b = list(map(int, input().split()))
c = {2: 1, 1: 2}
d = 2
for i in range(a):
	if b[i] == 1:
		print(d)
	elif b[i] % 2 == 0:
		print(c[d])
		d = c[d]
	else:
		print(d)


n = int(input())
list = []
list = map(int, input().split())
result = []
sum = 0
for elem in list:
	sum = sum + elem - 1
	result.append(sum)
for elem in result:
	if elem % 2 == 0:
		print('2')
	else:
		print('1')


k = int(input())
ciclos = list(map(int, input().split()))
soma = 0
for i in range(k):
	soma += ciclos[i] - 1
	print(2 if soma % 2 == 0 else 1)


try:
	while True:
		n = int(input())
		prev = 0
		for x in map(int, input().split()):
			prev = prev + x - 1 & 1
			print('21'[prev])
except EOFError:
	pass


N = int(input())
A = list(map(int, input().split()))
now = 0
for a in A:
	now += a - 1
	if now % 2 == 0:
		print(2)
	else:
		print(1)


n = int(input())
m = list(map(int, input().split()))
last = 2
ans = list()
for i in range(n):
	last = (m[i] - 1 + last) % 2
	if last == 0:
		last = 2
	ans.append(last)
ans = map(str, ans)
print('\n'.join(ans))


n = int(input())
a = list(map(int, input().split()))
x = 0
for y in a:
	x += y - 1
	if x % 2 == 1:
		print(1)
	else:
		print(2)


n = int(input())
a = list(map(int, input().split()))
even = 0
for ai in a:
	even += ai % 2 == 0
	print(list([2, 1])[even % 2])


n = int(input())
now = 2
for i in input().split():
	a = int(i)
	if a % 2 == 0:
		now = 3 - now
	print(now)


from sys import stdin, stdout
n = int(stdin.readline())
sizes = list(map(int, stdin.readline().split()))
if sizes[0] % 2:
	label = 'F'
else:
	label = 'W'
if label == 'W':
	stdout.write('1' + '\n')
else:
	stdout.write('2' + '\n')
for i in range(1, n):
	if label == 'W' and (not sizes[i] % 2):
		label = 'F'
	elif label == 'F' and (not sizes[i] % 2):
		label = 'W'
	if label == 'W':
		stdout.write('1' + '\n')
	else:
		stdout.write('2' + '\n')


n = int(input())
c = 1
for i in list(map(int, input().split())):
	c += i - 1
	print(c % 2 + 1)


n = int(input())
a = [int(z) - 1 for z in input().split()]
s = 0
for i in a:
	s += i
	if s % 2:
		print(1)
	else:
		print(2)


def nimber(x):
	return (x + 1) % 2
N = int(input())
current = 0
A = list(map(int, input().split()))
for a in A:
	current = current ^ nimber(a)
	print(1 if current != 0 else 2)


n = int(input())
l = map(int, input().split())
ans = 0
for e in l:
	ans += e - 1
	if ans > 0 and ans % 2:
		print(1)
	else:
		print(2)


t = int(input())
q = map(int, input().split())
sum = 0
for i in q:
	sum += i - 1
	if sum % 2 == 0:
		print('2')
	else:
		print('1')


n = int(input())
a = [int(x) for x in input().split()]
d = 2
c = 0
e = 0
for x in a:
	if x == 1:
		print(d)
		continue
	if x % 2 == 0:
		if d == 2:
			d = 1
		else:
			d = 2
	print(d)


import sys
n = int(sys.stdin.readline())
a = map(int, sys.stdin.readline().split())
moves = 0
for i in a:
	moves += i - 1
	if moves % 2 == 1:
		print('1')
	else:
		print('2')


n = int(input())
a = list(map(int, input().split()))

def solve(a):
	s = 0
	res = []
	for v in a:
		s += v - 1
		if s % 2 == 0:
			res.append('2')
		else:
			res.append('1')
	return ' '.join(res)
print(solve(a))


t = int(input())
tests = [int(i) for i in input().split()]
current = []
am = 0
for i in range(t):
	if tests[i] % 2 == 0:
		am += 1
	if am % 2 == 0:
		print(2)
	else:
		print(1)


n = int(input())
loops = input()
loops = loops.split()
loops = list(map(int, loops))
i = 0
oldCount = 0
while i < n:
	currentTotal = oldCount + loops[i]
	oldCount = currentTotal % 2 and 2 or 1
	print(oldCount)
	i += 1


n = int(input())
a = input().split()
s = 0
for i in range(n):
	s = s + int(a[i]) - 1
	print(1 - s % 2 + 1)


class CodeforcesTask705BSolution:

	def __init__(self):
		self.result = ''
		self.cycles = []

	def read_input(self):
		input()
		self.cycles = [int(x) for x in input().split(' ')]

	def process_task(self):
		moves = 0
		for x in range(len(self.cycles)):
			moves += self.cycles[x] - 1
			print('{0}'.format((moves + 1) % 2 + 1))

	def get_result(self):
		return self.result
Solution = CodeforcesTask705BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
sum = 0
l = list(map(int, input().split()))
for x in l:
	sum += x - 1
	if sum & 1:
		print(1)
	else:
		print(2)


def solution(arr):
	sum = 0
	for i in arr:
		sum += i - 1
		if sum % 2 == 0:
			print('2')
		else:
			print('1')
test = int(input())
ar = [int(x) for x in input().split()]
solution(ar)


import os, sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	a = list(map(int, input().split()))
	eve = 0
	for i in a:
		if not i & 1:
			eve ^= 1
		print((eve ^ 1) + 1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
nums = input().split()
r = True
for i in nums:
	x = int(i)
	if x % 2 == 0:
		r = not r
	print(int(r) + 1)


def main():
	(n, l, v) = (int(input()), input().split(), 0)
	for (i, a) in enumerate(l):
		v ^= ord(a[-1]) - 1
		l[i] = ('2', '1')[v & 1]
	print('\n'.join(l))
main()


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	a[i] -= 1
	a[i] = a[i] % 2
win = a[0] % 2
print(2 - win)
for i in range(1, n):
	if a[i]:
		win ^= 1
	print(2 - win)


import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
winner = 0
for i in range(n):
	winner = (winner + a[i] - 1) % 2
	print(2 - winner)


n = int(input())
numbers = [int(i) for i in input().split()]
odd = 0
even = 0
winner = 1
for i in numbers:
	if i % 2 == 0:
		winner += 1
	print(winner % 2 + 1)


n = int(input())
acc_par = 0
for x in map(int, input().split()):
	if x % 2 == 0:
		acc_par += 1
	if acc_par % 2 == 0:
		print(2)
	else:
		print(1)


temp = int(input())
temp = input().split()
cyc = [int(k) for k in temp]
win = cyc[0] % 2
print(win + 1)
all1 = True if cyc[0] == 1 else False
for i in range(1, len(cyc)):
	if cyc[i] == 1:
		print(win + 1)
		continue
	if all1:
		win = cyc[i] % 2
	elif cyc[i] % 2 != win:
		win = 0
	elif win == 0:
		win = (win + 1) % 2
	all1 = False
	print(win + 1)


n = int(input())
s = 0
xs = [int(x) for x in input().split()]
for x in xs:
	s += x - 1
	if s % 2 == 0:
		print(2)
	else:
		print(1)


n = int(input())
data = list(map(int, input().split()))
ans = 0
for i in data:
	ans += i - 1
	if ans % 2 == 0:
		print('2')
	else:
		print('1')


n = input()
i = 0
for k in input().split(' '):
	i += int(k) - 1
	if i % 2 == 0:
		print(2)
	else:
		print(1)


q = int(input())
a = [int(i) for i in input().split()]
s = 0
for i in range(q):
	s += a[i] - 1
	if s % 2 == 0:
		print(2)
	else:
		print(1)


amount = int(input())
cycles = [int(i) - 1 for i in input().split()]
prev = (cycles[0] + 1) % 2 + 1
print(prev)
for i in range(amount - 1):
	prev = (prev + cycles[i + 1] + 1) % 2 + 1
	print(prev)


input()
w = 1
for x in map(int, input().split()):
	w ^= (x - 1) % 2
	print(w + 1)


r = 0
for x in map(int, [*open(0)][1].split()):
	r = (r + x - 1) % 2
	print([2, 1][r])


n = int(input())
a = list(map(int, input().strip().split()))
sum = 0
for x in range(0, n):
	sum = sum + a[x] - 1
	if sum % 2 == 0:
		print(2)
	else:
		print(1)


def who_wins():
	n = int(input())
	cycles = (int(cyc) for cyc in input().split())
	moves = 0
	for cyc in cycles:
		moves += cyc - 1
		if moves % 2 == 1:
			print('1')
		else:
			print('2')
who_wins()


n = int(input())
l = list(input().split())
l = [int(i) for i in l]
winner = 1
for i in l:
	if not i % 2:
		winner = not winner
		print(int(winner) + 1)
	else:
		print(int(winner) + 1)


n = int(str(input()))
inp = input().strip().split()
inp = [int(i) for i in inp]
cur = 0
for val in inp:
	cur = (cur + (val - 1) % 2) % 2
	if cur == 1:
		print(1)
	else:
		print(2)


n = int(input())
li = list(map(int, input().split()))
f = 2
for i in li:
	if i % 2 == 0:
		if f == 2:
			print('1')
			f = 1
		else:
			print('2')
			f = 2
	elif f == 2:
		print('2')
	else:
		print('1')


def arr_inp():
	return [int(x) for x in stdin.readline().split()]
from sys import stdin
(n, a, sum) = (int(input()), arr_inp(), 0)
for i in a:
	if i != 1:
		sum += i - 1
	print(1 if sum & 1 else 2)


import sys
from decimal import *

def main():
	n = int(sys.stdin.readline())
	x = list(map(int, sys.stdin.readline().split()))
	ans = []
	cur = 0
	for i in x:
		cur += i - 1
		if cur % 2 == 0:
			ans.append('2')
		else:
			ans.append('1')
	print('\n'.join(ans))
main()


n = int(input())
inp = list(map(int, input().split()))
ans = 0
a = [0] * 100
for i in inp:
	if i == 1:
		ans += 0
	else:
		ans += i - 2 + 1
	if ans % 2 == 0:
		print('2')
	else:
		print('1')


n = int(input().strip())
cycles = list(map(int, input().strip().split()))
n_steps = 0
for c in cycles:
	n_steps += c - 1
	print(int(not n_steps % 2) + 1)


n = int(input())
a = list((int(x) for x in input().split()))
curwin = -1
if a[0] % 2 == 0:
	curwin = 1
else:
	curwin = 2
print(curwin)
for i in range(1, len(a)):
	if a[i] % 2 == 0:
		curwin = 3 - curwin
	print(curwin)


n = int(input())
seq = [int(c) for c in input().split()]
winner = 2
out = []
for e in seq:
	if e % 2 == 0:
		winner = 2 if winner == 1 else 1
	out.append(winner)
print('\n'.join(map(str, out)))


t = int(input())
v = list(map(int, input().strip().split()))
n = len(v)
steps = 0
for i in range(n):
	if v[i] != 1:
		steps += v[i] - 1
	if steps % 2 == 0:
		print(2)
	else:
		print(1)


from sys import stdin, stdout
n = int(input())
cycles = list(map(int, stdin.readline().split()))
total = 0
for i in range(n):
	cycle = cycles[i]
	aretes = cycle - 1
	total = (total + aretes) % 2
	if total % 2 == 0:
		stdout.write('2' + '\n')
	else:
		stdout.write('1' + '\n')


n = int(input())
a = list(map(int, input().split()))
b = []
c = 0
if a[0] == 1:
	print(2)
	prev = 2
	c = 0
elif a[0] % 2 == 0:
	print(1)
	prev = 1
	c = a[0] - 1
elif a[0] % 2 != 0:
	print(2)
	prev = 2
	c = a[0] - 1
b.append(a[0])
for i in range(1, n):
	b.append(a[i])
	if a[i] == 1:
		print(prev)
		c = c + 0
	else:
		c = c + a[i] - 1
		if c % 2 == 0:
			print(2)
			prev = 2
		else:
			print(1)
			prev = 1


n = int(input())
b = [0] * n
sum = 0
i = 0
for s in input().split():
	sum += int(s) - 1
	b[i] = sum
	i += 1
for i in range(n):
	print(2 - b[i] % 2)


def conj(e):
	return 2 if e == 1 else 1
n = int(input())
a = list(map(int, input().split()))
c = 1
ans = []
for i in range(n):
	if a[i] % 2 != 0:
		ans.append(conj(c))
	else:
		ans.append(c)
		c = conj(c)
for it in ans:
	print(it)


winer = 2
loser = 1
n = int(input())
xs = list(map(int, input().split()))
for x in xs:
	if x == 1:
		pass
	elif x % 2 == 0:
		(winer, loser) = (loser, winer)
	else:
		pass
	print(winer)


import time
n = int(input())
a = [int(i) for i in input().split()]
steps = 0
ans = []
start = time.time()
for now in a:
	steps += now - 1
	if steps % 2 == 0:
		ans.append(2)
	else:
		ans.append(1)
for now in ans:
	print(now)
finish = time.time()


n = int(input())
a = list(map(int, input().split()))
if a[0] % 2 == 1:
	print(2)
	ans = 2
elif a[0] % 2 == 0:
	print(1)
	ans = 1
for i in range(1, len(a)):
	if a[i - 1] % 2 == 0 and a[i] % 2 == 0:
		if ans == 2:
			print(1)
			ans = 1
		else:
			print(2)
			ans = 2
	elif a[i - 1] % 2 == 0 and a[i] % 2 == 1:
		print(ans)
	elif a[i - 1] % 2 == 1 and a[i] % 2 == 0:
		if ans == 2:
			print(1)
			ans = 1
		else:
			print(2)
			ans = 2
	elif a[i - 1] % 2 == 1 and a[i] % 2 == 1:
		print(ans)


n = int(input())
Tests = list(map(int, input().split()))
Results = []
for i in range(n):
	if len(Results) == 0:
		if Tests[i] % 2 == 0:
			print(1)
			Results.append(1)
		else:
			print(2)
			Results.append(2)
	elif Tests[i] % 2 == 0:
		if Results[-1] == 1:
			print(2)
			Results.append(2)
		else:
			print(1)
			Results.append(1)
	elif Results[-1] == 1:
		print(1)
		Results.append(1)
	else:
		print(2)
		Results.append(2)


n = int(input())
a = [int(i) for i in input().split()]
moves = 0
for i in range(n):
	moves += a[i] - 1
	if moves == 0 or moves % 2 == 0:
		print(2)
	else:
		print(1)


n = int(input())
a = list(map(lambda x: int(x) - 1, input().split()))
s = a[0]
for i in range(1, n):
	s += a[i]
	a[i] = s
print('\n'.join((('2', '1')[a[i] % 2] for i in range(n))))


def f(l):
	n = len(l)
	rl = [0] * n
	rl[0] = l[0] % 2 + 1
	for i in range(1, n):
		rl[i] = rl[i - 1] if l[i] % 2 > 0 else 3 - rl[i - 1]
	return rl
q = int(input())
l = list(map(int, input().split()))
[print(r) for r in f(l)]


n = int(input())
l = list(map(int, input().split()))
t = 0
for i in l:
	t = t + i - 1
	if t % 2 == 0:
		print(2)
	else:
		print(1)


n = int(input())
A = list(map(int, input().split()))
Z = 0
for a in A:
	Z += a - 1
	if Z % 2 == 0:
		print(2)
	else:
		print(1)


ans = 0
(x, y) = (int(input()), input().split())
for i in range(x):
	ans = ans + int(y[i]) - 1
	print(1 if ans % 2 else 2)


cantidad = int(input())
vectorCycles = [int(n) for n in input().split()]
turnos = 0
for i in range(cantidad):
	turnos += vectorCycles[i] - 1
	if turnos % 2 == 0:
		print('2')
	else:
		print('1')


n = int(input())
val = list(map(int, input().split()))
ans = [0] * n
ans[0] = 1 if val[0] % 2 == 0 else 2
for i in range(1, n):
	if val[i] % 2 == 1:
		ans[i] = ans[i - 1]
	else:
		ans[i] = ans[i - 1] % 2 + 1
print('\n'.join(map(str, ans)))


n = int(input())
a = [int(i) for i in input().split(' ')]
sum = 0
for x in range(n):
	sum += a[x]
	b = sum - x
	print(b % 2 + 1)


n = int(input())
ai = list(map(int, input().split()))
win = 2
for i in ai:
	if i % 2 == 0:
		win = 3 - win
	print(win)


def change(ans):
	if ans == 1:
		ans = 2
	else:
		ans = 1
	return ans
n = int(input())
array = list(map(int, input().split()))
if array[0] % 2 != 0:
	ans = 2
else:
	ans = 1
print(ans)
for i in range(1, n):
	if array[i] % 2 == 0:
		ans = change(ans)
	print(ans)


a = [int(x) for x in input().split()][0]
arr = [int(x) for x in input().split()]
if arr[0] % 2 == 1:
	pre = 2
else:
	pre = 1
print(pre)
for i in range(1, a):
	if arr[i] % 2 == 1:
		cur = 2
	else:
		cur = 1
	if pre == 1 and cur == 1:
		print(2)
		pre = 2
	elif pre == 1 and cur == 2:
		print(1)
		pre = 1
	elif pre == 2 and cur == 1:
		print(1)
		pre = 1
	elif pre == 2 and cur == 2:
		print(2)
		pre = 2


def s():
	n = int(input())
	su = 1
	for i in map(int, input().split()):
		su += i - 1
		print(su % 2 + 1)
s()


import sys
n = int(sys.stdin.readline().strip())
ints = list(map(int, sys.stdin.readline().split()))
x = 0
for i in range(n):
	x += ints[i] - 1
	if x % 2 == 1:
		print(1)
	else:
		print(2)


n = int(input())
a = list(map(int, input().split()))
answers = []
summa = 0
if a[0] == 1:
	answers.append(2)
else:
	if (a[0] - 1) % 2 == 0:
		answers.append(2)
	else:
		answers.append(1)
	summa += a[0] - 1
for i in range(1, n):
	v = a[i]
	if v == 1:
		answers.append(answers[-1])
		continue
	summa += v - 1
	if summa % 2 == 0:
		answers.append(2)
	else:
		answers.append(1)
for i in range(n):
	print(answers[i])


n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
	ans += l[i] - 1
	if ans % 2 == 0:
		print(2)
	else:
		print(1)


n = int(input())
Test = list(map(int, input().split()))
summa = 0
for i in range(len(Test)):
	summa += Test[i] - 1
	if summa % 2 == 1:
		print(1)
	else:
		print(2)


i = int(input())
cikles = input().split()
sum = 0
j = 0
while j < i:
	sum += int(cikles[j])
	if (sum - j + 1) % 2 == 0:
		print(2)
	else:
		print(1)
	j += 1


def cycle_winner():
	input()
	winner = 2
	for vertice in map(int, input().split()):
		winner = (3 - winner, winner)[vertice % 2]
		print(winner)
cycle_winner()


def get_ints(string):
	return list(map(int, string.split()))

def get_input():
	a = get_ints(input())
	return a

def main():
	n = int(input())
	xs = get_ints(input())
	res = 1
	for x in xs:
		res += x + 1
		print(res % 2 + 1)
main()


__author__ = 'Alexander'
import sys
n = int(sys.stdin.readline().strip())
graphs = map(int, sys.stdin.readline().split())
out = []
last = 0
for graph in graphs:
	if (last + graph - 1) % 2 == 0:
		out.append(2)
	else:
		out.append(1)
	last = (last + graph - 1) % 2
for i in out:
	sys.stdout.write(str(i) + '\n')


input()
f = 1
for i in map(int, input().split()):
	f ^= 1 & ~i
	print(1 + f)


from sys import stdin, stdout
import math
from operator import *
from collections import Counter, defaultdict
import heapq

def main():
	n = int(stdin.readline())
	A = list(map(int, stdin.readline().split()))
	B = [0] * n
	B[0] = A[0] - 1
	for i in range(1, n):
		B[i] = A[i] + B[i - 1] - 1
	for i in range(n):
		if B[i] % 2 == 0:
			print(2)
		else:
			print(1)
main()


n = int(input())
v = list(map(int, input().split()))
w = -1
l = 1
pos = l
for i in v:
	if i % 2 == 0:
		if pos == w:
			print(2)
			pos = l
		else:
			print(1)
			pos = w
	elif pos == l:
		print(2)
	else:
		print(1)
		pos = w


def nik(rud, panda):
	for i in range(n):
		panda = panda + int(rud[i]) - 1
		print(1) if panda % 2 else print(2)
n = int(input())
rud = list(map(int, input().split(' ')))
panda = 0
nik(rud, panda)


def spiderman(x, p):
	for i in range(n):
		p = p + int(x[i]) - 1
		print(1) if p % 2 else print(2)
n = int(input())
x = list(map(int, input().split(' ')))
p = 0
spiderman(x, p)


t = input
p = print
r = range
n = int(t())
a = list(map(int, t().split()))
current_winner = 1 if a[0] & 1 == 0 else 2
p(current_winner)
for i in r(1, n):
	local_winner = 1 if a[i] & 1 == 0 else 2
	if current_winner == 1:
		if local_winner == 1:
			current_winner = 2
	elif local_winner == 1:
		current_winner = 1
	p(current_winner)


n = int(input())
arr = list(map(int, input().split()))
win = 2
turn = 1
for i in range(n):
	if arr[i] != 1:
		if arr[i] % 2 == 1:
			print(3 - turn)
		else:
			turn = 3 - turn
			print(3 - turn)
	else:
		print(3 - turn)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
from bisect import bisect_left as lower_bound, bisect_right as upper_bound

def so():
	return int(input())

def st():
	return input()

def mj():
	return map(int, input().strip().split(' '))

def msj():
	return map(str, input().strip().split(' '))

def le():
	return list(map(int, input().split()))

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def tr(n):
	return n * (n + 1) // 2

def main():
	for i in range(1):
		m = so()
		L = le()
		p = 2
		for u in L:
			if u % 2 == 0:
				p = 3 - p
			print(p)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = list(map(int, input().split()))
ans = list()
c = 0
for el in a:
	c += el - 1
	ans.append([2, 1][c % 2])
print('\n'.join(map(str, ans)))


n = int(input())
lst = list(map(int, input().split()))
summa = 0
for (i, x) in enumerate(lst):
	summa += x - 1
	if summa % 2 == 0:
		print(2)
	else:
		print(1)