Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play $t$ matches of a digit game...

In each of $t$ matches of the digit game, a positive integer is generated. It consists of $n$ digits. The digits of this integer are numerated from $1$ to $n$ from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts.

Agents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins.

It can be proved, that before the end of the match (for every initial integer with $n$ digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity.

For each of $t$ matches find out, which agent wins, if both of them want to win and play optimally.


-----Input-----

First line of input contains an integer $t$ $(1 \le t \le 100)$  — the number of matches.

The first line of each match description contains an integer $n$ $(1 \le n \le 10^3)$  — the number of digits of the generated number.

The second line of each match description contains an $n$-digit positive integer without leading zeros.


-----Output-----

For each match print $1$, if Raze wins, and $2$, if Breach wins.


-----Example-----
Input
4
1
2
1
3
3
102
4
2069

Output
2
1
1
2



-----Note-----

In the first match no one can make a turn, the only digit left is $2$, it's even, so Breach wins.

In the second match the only digit left is $3$, it's odd, so Raze wins.

In the third match Raze can mark the last digit, after that Breach can only mark $0$. $1$ will be the last digit left, it's odd, so Raze wins.

In the fourth match no matter how Raze plays, Breach can mark $9$, and in the end there will be digit $0$. It's even, so Breach wins.

Difficulty: EASY
Tags: Game theory

Implementation

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
for _ in range(int(input())):
	n = int(input())
	a = str(input())
	r1 = ''
	r2 = ''
	b1 = ''
	b2 = ''
	for i in range(n):
		if i % 2 == 0:
			if int(a[i]) % 2 == 0:
				r2 += a[i]
			else:
				r1 += a[i]
		elif int(a[i]) % 2 == 0:
			b2 += a[i]
		else:
			b1 += a[i]
	if len(a) % 2 == 1:
		if len(r1) > 0:
			print(1)
			continue
		else:
			print(2)
			continue
	elif len(b2) > 0:
		print(2)
		continue
	else:
		print(1)
		continue


for tt in range(int(input())):
	n = int(input())
	num = int(input())
	l = list(str(num))
	ee = 0
	eo = 0
	oe = 0
	oo = 0
	for i in range(n):
		if (i + 1) % 2 == 0 and int(l[i]) % 2 == 0:
			ee += 1
		elif (i + 1) % 2 == 0 and int(l[i]) % 2 != 0:
			eo += 1
		elif (i + 1) % 2 != 0 and int(l[i]) % 2 == 0:
			oe += 1
		elif (i + 1) % 2 != 0 and int(l[i]) % 2 != 0:
			oo += 1
	if n % 2 == 0:
		if eo < n // 2:
			print(2)
		else:
			print(1)
	elif oe < (n + 1) // 2:
		print(1)
	else:
		print(2)


def If_Even(Str):
	n = len(Str)
	Even = False
	for i in range(int(n / 2)):
		if int(Str[2 * i + 1]) % 2 == 0:
			Even = True
	if Even == True:
		return 2
	else:
		return 1

def If_Odd(Str):
	n = len(Str)
	Odd = False
	for i in range(int(n / 2) + 1):
		if int(Str[2 * i]) % 2 == 1:
			Odd = True
	if Odd == True:
		return 1
	else:
		return 2

def Who_wins(Str):
	if len(Str) % 2 == 0:
		return If_Even(Str)
	else:
		return If_Odd(Str)
trials = int(input())
for i in range(trials):
	input('')
	Str = input('')
	print(Who_wins(Str))


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
for _ in range(II()):
	n = II()
	aa = [int(d) for d in SI()]
	if n & 1 and any((a & 1 for a in aa[0:n:2])) or (n & 1 == 0 and all((a & 1 for a in aa[1:n:2]))):
		print(1)
	else:
		print(2)


def solve(length, number):
	O = number[::2]
	E = number[1::2]
	if length % 2 == 0:
		for v in E:
			if v % 2 == 0:
				return 2
		return 1
	else:
		for v in O:
			if v % 2 == 1:
				return 1
		return 2
cases = int(input())
for k in range(cases):
	l = int(input())
	num = input()
	input_num = [int(i) for i in num]
	print(solve(l, input_num))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input()]
	if n % 2 == 0:
		even = 0
		for i in range(1, n, 2):
			if arr[i] % 2 == 0:
				even += 1
		if even > 0:
			print(2)
		else:
			print(1)
	else:
		odd = 0
		for i in range(0, n, 2):
			if arr[i] % 2 != 0:
				odd += 1
		if odd > 0:
			print(1)
		else:
			print(2)


for tt in range(int(input())):
	n1 = int(input())
	n2 = input()
	counts = [[0, 0], [0, 0]]
	for i in range(n1):
		counts[i % 2][int(n2[i]) % 2] += 1
	if n1 % 2 == 0 and counts[1][0] > 0:
		print(2)
	elif n1 % 2 == 0:
		print(1)
	elif counts[0][1] > 0:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline
for i in range(int(input())):
	n = int(input())
	lis = list(map(int, input().strip()))
	oe = 0
	eo = 0
	o = 0
	e = 0
	for i in range(n):
		if i % 2 == 0:
			o += 1
			if lis[i] % 2 == 0:
				oe += 1
		elif i % 2 == 1:
			e += 1
			if lis[i] % 2 == 1:
				eo += 1
	if n % 2 == 1 and o == oe:
		print(2)
	elif n % 2 == 1 and oe < o:
		print(1)
	elif n % 2 == 0 and e == eo:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input()))
	(c0, c1) = ([0, 0], [0, 0])
	for i in range(n):
		if i % 2:
			c1[l[i] % 2] += 1
		else:
			c0[l[i] % 2] += 1
	if n % 2:
		print(1 if c0[1] > 0 else 2)
	else:
		print(2 if c1[0] > 0 else 1)


t = int(input())
while t > 0:
	nd = int(input())
	s = input()
	re = 0
	ro = 0
	be = 0
	bo = 0
	i = 0
	while i < nd:
		if i % 2 == 0:
			if int(s[i]) % 2 == 0:
				re += 1
			else:
				ro += 1
		elif int(s[i]) % 2 == 0:
			be += 1
		else:
			bo += 1
		i += 1
	start = 1
	j = 0
	while j < nd - 1:
		if start == 1:
			if re > 0:
				re -= 1
			else:
				ro -= 1
			start = 2
		else:
			if bo > 0:
				bo -= 1
			else:
				be -= 1
			start = 1
		j += 1
	if re > 0 or be > 0:
		print(2)
	else:
		print(1)
	t -= 1


for t in range(int(input())):
	d = int(input())
	n = input()
	e = 0
	o = 0
	for i in range(d):
		if i % 2 == 0:
			if int(n[i]) % 2 == 1:
				o = 1
		if i % 2 == 1:
			if int(n[i]) % 2 == 0:
				e = 1
	if d % 2 == 0:
		if e == 1:
			print(2)
		else:
			print(1)
	elif o == 1:
		print(1)
	else:
		print(2)


import math
import itertools
t = int(input())
for _ in range(t):
	n = int(input())
	arr = input()
	if n == 1:
		print(1 if int(arr) % 2 == 1 else 2)
	else:
		odd_on_odd = any((int(arr[i]) % 2 == 1 for i in range(0, n, 2)))
		even_on_even = any((int(arr[i]) % 2 == 0 for i in range(1, n, 2)))
		if odd_on_odd and even_on_even:
			if n % 2 == 0:
				print(2)
			else:
				print(1)
		elif even_on_even and (not odd_on_odd):
			print(2)
		elif not even_on_even and odd_on_odd:
			print(1)
		elif n % 2 == 0:
			print(1)
		else:
			print(2)


tests = int(input())
for testnum in range(tests):
	n = int(input())
	numbers = list(input())
	numbers = list(map(int, numbers))
	raze = [numbers[i] for i in range(0, len(numbers), 2)]
	breach = [numbers[i] for i in range(1, len(numbers), 2)]
	razegotodd = len(list(filter(lambda x: x % 2 == 1, raze)))
	razegoteven = len(list(filter(lambda x: x % 2 == 0, raze)))
	breachgotodd = len(list(filter(lambda x: x % 2 == 1, breach)))
	breachgoteven = len(list(filter(lambda x: x % 2 == 0, breach)))
	finisher = 0
	if n % 2 == 1:
		finisher = 1
	else:
		finisher = 2
	if finisher == 1:
		if razegotodd > 0:
			print(1)
		else:
			print(2)
	elif breachgoteven > 0:
		print(2)
	else:
		print(1)


test = int(input())
while test > 0:
	n = int(input())
	no = int(input())
	sno = str(no)
	razeev = 0
	razeod = 0
	breachev = 0
	breachod = 0
	for i in range(0, n):
		if i % 2 == 1:
			if int(sno[i]) % 2 == 0:
				breachev += 1
			elif int(sno[i]) % 2 == 1:
				breachod += 1
		elif int(sno[i]) % 2 == 0:
			razeev += 1
		elif int(sno[i]) % 2 == 1:
			razeod += 1
	t = 1
	while t != n:
		if t % 2 == 1:
			if razeev != 0:
				razeev -= 1
			else:
				razeod -= 1
		elif t % 2 == 0:
			if breachod != 0:
				breachod -= 1
			else:
				breachev -= 1
		t += 1
	if razeod == 1 or breachod == 1:
		print('1')
	elif razeev == 1 or breachev == 1:
		print('2')
	test -= 1


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	n = ini()
	s = ins()
	if len(s) == 1:
		if int(s[0]) % 2 == 0:
			print(2)
			continue
		print(1)
		continue
	else:
		if n % 2 == 0:
			ans = 1
			for i in range(1, n, 2):
				if int(s[i]) % 2 == 0:
					ans = 2
					break
		else:
			ans = 2
			for i in range(0, n, 2):
				if int(s[i]) % 2 != 0:
					ans = 1
					break
		print(ans)


t = int(input())
while t > 0:
	n = int(input())
	d = int(input())
	res = list(map(int, str(d)))
	od = 0
	ev = 0
	for i in range(n):
		if i % 2 == 0:
			if res[i] % 2 == 1:
				od = od + 1
		elif res[i] % 2 == 0:
			ev = ev + 1
	if len(res) == 1:
		if d % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 1:
		if od > 0:
			print(1)
		else:
			print(2)
	elif ev > 0:
		print(2)
	else:
		print(1)
	t = t - 1


game = int(input())
for k in range(game):
	n = int(input())
	no = input()
	v = list(no)
	b = 0
	r = 0
	z = []
	for value in v:
		z.append(int(value))
	if n % 2 == 0:
		for i in range(1, n, 2):
			if z[i] % 2 == 0:
				b = 1
				break
		if b == 1:
			print(2)
		else:
			print(1)
	if n % 2 != 0:
		for i in range(0, n, 2):
			if z[i] % 2 != 0:
				r = 1
				break
		if r == 1:
			print(1)
		else:
			print(2)


import math
from collections import defaultdict
import functools as f
from itertools import permutations as p
t = int(input())
for _ in range(t):
	n = int(input())
	s = str(input())
	re = 0
	ro = 0
	be = 0
	bo = 0
	for i in range(n):
		if i % 2 == 0:
			k = s[i]
			k = int(k)
			if k % 2 != 0:
				ro += 1
			else:
				re += 1
		else:
			k = s[i]
			if int(k) % 2 == 0:
				be += 1
			else:
				bo += 1
	i = 1
	while True:
		if i == n:
			break
		if i % 2 != 0:
			if re != 0:
				re -= 1
			else:
				ro -= 1
		elif bo != 0:
			bo -= 1
		else:
			be -= 1
		i += 1
	if ro >= 1 or bo >= 1:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline
n = int(input().strip())
results = [0] * n
match = 0
while match < n:
	num_digits = int(input().strip())
	number = input()
	if num_digits % 2 == 0:
		found_even = False
		i = 1
		for digit in number:
			if i % 2 == 0 and int(digit) % 2 == 0:
				results[match] = 2
				break
			i += 1
		if results[match] == 0:
			results[match] = 1
	else:
		i = 1
		for digit in number:
			if i % 2 != 0 and int(digit) % 2 != 0:
				results[match] = 1
				break
			i += 1
		if results[match] == 0:
			results[match] = 2
	match += 1
for winner in results:
	print(winner)


testcases = int(input())
for _ in range(testcases):
	n = int(input())
	a = input()
	if n == 1:
		print(2 if int(a) % 2 == 0 else 1)
		continue
	count = 0
	if n % 2 == 0:
		s = a[1::2]
		for i in s:
			if int(i) % 2 == 0:
				count += 1
		print(2 if count > 0 else 1)
	else:
		s = a[::2]
		for i in s:
			if int(i) % 2 != 0:
				count += 1
		print(1 if count > 0 else 2)


t = int(input())
while t:
	t += -1
	n = int(input())
	s = list(input())
	(ocntodd, ocnteven, ecntodd, ecnteven) = (0, 0, 0, 0)
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2:
				ocntodd -= -1
			else:
				ocnteven -= -1
		elif int(s[i]) % 2:
			ecntodd -= -1
		else:
			ecnteven -= -1
	if n % 2:
		if ocntodd:
			print(1)
		else:
			print(2)
	elif ecnteven:
		print(2)
	else:
		print(1)


for case in range(int(input())):
	n = int(input())
	num = input()
	lst1 = []
	lst2 = []
	for i in range(1, n + 1):
		if i % 2 == 0:
			lst1.append(int(num[i - 1]))
		else:
			lst2.append(int(num[i - 1]))
	if n % 2 != 0:
		pointer = '2'
		for i in lst2:
			if i % 2 != 0:
				pointer = '1'
				break
		print(pointer)
	else:
		pointer = '1'
		for i in lst1:
			if i % 2 == 0:
				pointer = '2'
				break
		print(pointer)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	l = []
	if n % 2 != 0:
		for i in range(len(s)):
			if (i + 1) % 2 != 0:
				l.append(int(s[i]))
		for i in range(len(l)):
			if l[i] % 2 != 0:
				print(1)
				break
		else:
			print(2)
	else:
		for i in range(len(s)):
			if (i + 1) % 2 == 0:
				l.append(int(s[i]))
		for i in range(len(l)):
			if l[i] % 2 == 0:
				print(2)
				break
		else:
			print(1)


test = int(input())
for i in range(test):
	n = int(input())
	s = input()
	odd = 0
	even = 0
	if n % 2 == 0:
		for i in range(n):
			if i % 2 != 0:
				if int(s[i]) % 2 == 0:
					even = 1
	else:
		for i in range(n):
			if i % 2 == 0:
				if int(s[i]) % 2 != 0:
					odd = 1
	if n % 2 == 0:
		if even == 1:
			print(2)
		else:
			print(1)
	elif odd == 1:
		print(1)
	else:
		print(2)


def solve():
	k = int(input())
	n = input()
	if len(n) == 1:
		print(1 if int(n) % 2 else 2)
		return
	ok1 = False
	ok2 = False
	for (i, v) in enumerate(n):
		v = int(v)
		if (i + 1) % 2 == 0 and v % 2 == 0:
			ok2 = True
		if (i + 1) % 2 == 1 and v % 2 == 1:
			ok1 = True
	if len(n) % 2:
		if ok1:
			print(1)
		else:
			print(2)
	elif ok2:
		print(2)
	else:
		print(1)
	return

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = rs()
		(nee, noe, neo, noo) = (0, 0, 0, 0)
		for i in range(n):
			k = ord(a[i]) - 48
			if (i + 1) % 2 == 0:
				if k % 2 == 0:
					nee += 1
				else:
					noe += 1
			elif k % 2 == 0:
				neo += 1
			else:
				noo += 1
		if n % 2 == 0:
			if nee > 0:
				print(2)
			else:
				print(1)
		elif noo > 0:
			print(1)
		else:
			print(2)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


T = int(input())
for I in range(0, T):
	N = int(input())
	X = input()
	if N % 2 == 0:
		M = X[1::2]
		for J in M:
			R = True
			if int(J) % 2 == 0:
				print(2)
				R = False
				break
		if R:
			print(1)
	else:
		M = X[0::2]
		for J in M:
			R = True
			if int(J) % 2 == 1:
				print(1)
				R = False
				break
		if R:
			print(2)


for s in [*open(0)][2::2]:
	f = len(s) % 2
	print('2112'[f + 2 * any((f ^ int(i) & 1 for i in s[f::2]))])


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	even = 0
	odd = 0
	if len(s) % 2 != 0:
		for i in range(n):
			if int(s[i]) % 2 == 1 and i % 2 == 0:
				odd += 1
		if odd >= 1:
			print(1)
		else:
			print(2)
	else:
		for i in range(n):
			if int(s[i]) % 2 == 0 and i % 2 != 0:
				even += 1
		if even >= 1:
			print(2)
		else:
			print(1)


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
from sys import stdin, stdout
import os
import sys
from io import BytesIO, IOBase
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')
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	s = input()
	if n == 1:
		if int(s[0]) % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	arR = []
	arB = []
	for i in range(n):
		if i % 2 == 0:
			arR.append(int(s[i]) % 2)
		else:
			arB.append(int(s[i]) % 2)
	arR.sort()
	arB.sort(reverse=True)
	if n % 2 == 1:
		if arR[len(arR) - 1] % 2 == 1:
			print(1)
		else:
			print(2)
	elif arB[len(arB) - 1] % 2 == 0:
		print(2)
	else:
		print(1)
sys.exit(0)
n = int(input())
lis = list(map(int, input().split()))
answer = 0
for i in range(n):
	answer += lis[i] - 1
if n == 1:
	print(n - 1)
elif n > 32:
	print(answer)
	sys.exit(0)
lis.sort()
for i in range(2, 50000):
	localMin = 0
	for j in range(n):
		needVal = i ** j
		localMin += abs(lis[j] - needVal)
		if localMin > answer:
			break
	else:
		answer = min(localMin, answer)
print(answer)
sys.exit(0)

class Person:

	def __init__(self, name, age):
		self.name = name
		self.age = age
p1 = Person('heelo', 27)
print(help(Person))
age = 26
name = 'Swaroop'
print('Возрас {} -- {} лет'.format(name, age))
print(help(object))


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
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 binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)
for xyz in range(0, int(input())):
	n = int(input())
	s = input()
	if n % 2 == 0:
		f = True
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				print(2)
				f = False
				break
		if f:
			print(1)
	else:
		f = True
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 1:
				print(1)
				f = False
				break
		if f:
			print(2)


for _ in range(int(input())):
	x = int(input())
	y = int(input())
	k = 1
	if x % 2 == 0:
		while y != 0:
			if y % 10 % 2 == 0:
				k = 2
				break
			y = y // 100
	else:
		k = 2
		while y != 0:
			if y % 10 % 2 == 1:
				k = 1
				break
			y = y // 100
	print(k)


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


N = int(input())
for i in range(N):
	digit = int(input())
	num = input()
	num.zfill(digit)
	ans = 0
	if digit % 2 == 0:
		Raze_win = True
		for i in range(1, digit, 2):
			if int(num[i]) % 2 == 0:
				Raze_win = False
				break
	else:
		Raze_win = False
		for i in range(0, digit, 2):
			if int(num[i]) % 2 != 0:
				Raze_win = True
				break
	if Raze_win:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	num = int(input())
	num = str(num)
	o = 0
	if n % 2 != 0:
		for i in range(n):
			if int(num[i]) % 2 != 0 and (i + 1) % 2 != 0:
				o += 1
		if o > 0:
			ans = 1
		else:
			ans = 2
	else:
		e = 0
		for i in range(n):
			if int(num[i]) % 2 == 0 and (i + 1) % 2 == 0:
				e += 1
		if e > 0:
			ans = 2
		else:
			ans = 1
	print(ans)


for _ in range(int(input())):
	(d, n) = (int(input()), input())
	raze = d % 2 != 0
	p = [int(x) % 2 != 0 for x in n]
	if len(p) == 1:
		print(2 if p[0] % 2 == 0 else 1)
	elif raze:
		if any(p[::2]):
			print(1)
		else:
			print(2)
	elif any([not x for x in p][1::2]):
		print(2)
	else:
		print(1)


import math
t = int(input())
for i in range(t):
	n = int(input())
	act = input()
	if n == 1:
		xx = 0
		if int(act) % 2 == 0:
			print(2)
		else:
			print(1)
			while False:
				break
		continue
	xx = 0
	if n % 2 == 0:
		check = False
		for j in range(1, n, 2):
			if int(act[j]) % 2 == 0:
				check = True
				break
		if check:
			print(2)
		else:
			print(1)
		while False:
			break
	else:
		xx = 0
		check = False
		for j in range(0, n, 2):
			if int(act[j]) % 2 == 1:
				check = True
				break
		if check:
			print(1)
		else:
			print(2)


from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	n = I()
	s = input()
	o = 0
	e = 0
	for i in range(n):
		if i % 2:
			if int(s[i]) % 2 == 0:
				e = 1
		elif int(s[i]) % 2 == 1:
			o = 1
	if n % 2:
		if o:
			print(1)
		else:
			print(2)
	elif e:
		print(2)
	else:
		print(1)


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		num = str(int(input()))
		if n % 2 == 0:
			c = 0
			for i in range(1, n + 1):
				if i % 2 == 0:
					if int(num[i - 1]) % 2 != 0:
						continue
					else:
						c = 1
						print(2)
						break
			if c == 0:
				print(1)
		else:
			c = 0
			for i in range(1, n + 1):
				if i % 2 != 0:
					if int(num[i - 1]) % 2 != 0:
						print(1)
						c = 1
						break
			if c == 0:
				print(2)
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()


def process():
	n = int(input())
	li = list(map(int, list(input())))
	odd_odd = 0
	even_odd = 0
	for i in range(0, n, 2):
		if li[i] % 2 == 1:
			odd_odd += 1
		else:
			even_odd += 1
	odd_even = 0
	even_even = 0
	for i in range(1, n, 2):
		if li[i] % 2 == 1:
			odd_even += 1
		else:
			even_even += 1
	if n % 2 == 1 and odd_odd > 0:
		return '1'
	elif n % 2 == 1:
		return '2'
	if n % 2 == 0 and even_even > 0:
		return '2'
	else:
		return '1'
tests = int(input())
for i in range(tests):
	print(process())


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	od = 0
	ev = 0
	for i in range(n):
		if i % 2 == 0 and int(s[i]) % 2 != 0:
			od = 1
		if i % 2 != 0 and int(s[i]) % 2 == 0:
			ev = 1
	if n % 2 == 0:
		if ev == 1:
			print('2')
		else:
			print('1')
	if n % 2 != 0:
		if od == 1:
			print('1')
		else:
			print('2')


def solve():
	n = int(input().strip())
	s = input().strip()
	ee = 0
	oo = 0
	eo = 0
	oe = 0
	for i in range(n):
		num = ord(s[i]) - ord('0')
		is_even = num % 2 == 0
		is_even_pos = (i + 1) % 2 == 0
		if is_even_pos:
			if is_even:
				ee += 1
			else:
				eo += 1
		elif is_even:
			oe += 1
		else:
			oo += 1
	winner = 0
	if n == 1:
		if int(s) % 2 == 0:
			winner = 2
		else:
			winner = 1
	elif n % 2 == 0:
		if ee > 0:
			winner = 2
		else:
			winner = 1
	elif oo > 0:
		winner = 1
	else:
		winner = 2
	print(winner)
t = int(input().strip())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip()))
	f = 2
	if n & 1:
		for v in a[::2]:
			if v & 1:
				f = 1
				break
	else:
		f = 1
		for v in a[1::2]:
			if not v & 1:
				f = 2
				break
	print(f)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	flag = 0
	if n == 1:
		if int(s) % 2 == 0:
			print('2')
		else:
			print('1')
	elif n % 2 == 0:
		i = 1
		while i < n:
			if int(s[i]) % 2 == 0:
				flag = 1
				print('2')
				break
			i += 2
		if flag == 0:
			print('1')
	else:
		i = 0
		while i < n:
			if int(s[i]) % 2 != 0:
				flag = 1
				print('1')
				break
			i += 2
		if flag == 0:
			print('2')


import sys
from sys import stdin
import math

def iinput():
	return int(input())

def minput():
	return map(int, input().split())

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

def fiinput():
	return int(stdin.readline())

def fminput():
	return map(int, stdin.readline().strip().split())

def flinput():
	return list(map(int, stdin.readline().strip().split()))
for _ in range(iinput()):
	n = iinput()
	s = input()
	list1 = list(map(int, s))
	c1 = 0
	c2 = 0
	d1 = 0
	d2 = 0
	for i in range(n):
		if i % 2 == 0 and list1[i] % 2 != 0:
			c1 += 1
		if i % 2 == 0 and list1[i] % 2 == 0:
			c2 += 1
		if i % 2 != 0 and list1[i] % 2 != 0:
			d1 += 1
		if i % 2 != 0 and list1[i] % 2 == 0:
			d2 += 1
	turn = 0
	while n > 1:
		if turn == 0:
			if c2:
				c2 -= 1
			else:
				c1 -= 1
			turn = 1
		else:
			if d1:
				d1 -= 1
			else:
				d2 -= 1
			turn = 0
		n -= 1
	if c1 or d1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(re, ro, be, bo) = (0, 0, 0, 0)
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2 != 0:
				ro += 1
			else:
				re += 1
		elif int(s[i]) % 2 == 0:
			be += 1
		else:
			bo += 1
	if n % 2 == 0:
		print(2 if be else 1)
	else:
		print(1 if ro else 2)


t = int(input())
for _ in range(t):
	n = int(input())
	num = int(input())
	has_odd_odd = False
	has_eve_eve = False
	num = list(map(int, str(num)))
	for (index, d) in enumerate(num):
		if d % 2 == 0 and (index + 1) % 2 == 0:
			has_eve_eve = True
		if d % 2 == 1 and (index + 1) % 2 == 1:
			has_odd_odd = True
	if n % 2 == 0:
		if has_eve_eve:
			print(2)
		else:
			print(1)
	elif has_odd_odd:
		print(1)
	else:
		print(2)


import math
from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	s = list(s)
	l = s
	if n % 2 == 0:
		f = 0
		for i in range(n):
			if i % 2 == 1:
				if int(l[i]) % 2 == 0:
					f = 1
		if f == 1:
			print(2)
		else:
			print(1)
	else:
		f = 0
		for i in range(n):
			if i % 2 == 0:
				if int(l[i]) % 2 == 1:
					f = 1
		if f == 1:
			print(1)
		else:
			print(2)


from sys import stdin, stdout
from collections import defaultdict
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	num = input()
	ans = 0
	if n % 2:
		for i in range(0, n, 2):
			if int(num[i]) % 2:
				ans = 1
				break
		else:
			ans = 2
	else:
		for i in range(1, n, 2):
			if int(num[i]) % 2 == 0:
				ans = 2
				break
		else:
			ans = 1
	print(ans)


def digit_game():
	matchCount = int(input())
	count = 1
	digitCountArry = []
	numberArry = []
	while count <= matchCount:
		digitCountArry.append(int(input()))
		numberArry.append(input())
		count = count + 1
	for index in range(0, matchCount):
		digitCount = digitCountArry[index]
		number = numberArry[index]
		if digitCount == 1:
			if int(number) % 2 == 0:
				print(2)
			else:
				print(1)
		elif digitCount % 2 == 0:
			pos = 1
			isBreachWon = None
			while pos < digitCount:
				if int(number[pos]) % 2 == 0:
					isBreachWon = True
					break
				pos = pos + 2
			print(2) if isBreachWon else print(1)
		else:
			pos = 0
			isRazeWon = None
			while pos < digitCount:
				if int(number[pos]) % 2 != 0:
					isRazeWon = True
					break
				pos = pos + 2
			print(1) if isRazeWon else print(2)
digit_game()


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
import sys
letters = ascii_letters[:26]
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	x = input().strip()
	if n % 2:
		can = [int(i) for (ind, i) in enumerate(x) if not ind % 2]
		if any(map(lambda a: a % 2, can)):
			print(1)
		else:
			print(2)
	else:
		can = [int(i) for (ind, i) in enumerate(x) if ind % 2]
		if any(map(lambda a: not a % 2, can)):
			print(2)
		else:
			print(1)


def countd(n, ar):
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(ar[i]) % 2 == 0:
				return 2
		return 1
	else:
		for i in range(0, n, 2):
			if int(ar[i]) % 2 != 0:
				return 1
		return 2
t = int(input())
for i in range(t):
	n = int(input())
	ar = input()
	m = countd(n, ar)
	print(m)


def main(val, l):
	arr = list(val)
	if l == 1:
		return 2 if int(arr[0]) % 2 == 0 else 1
	Raze = arr[::2]
	Breach = arr[1::2]
	if l % 2 == 1:
		for x in Raze:
			if int(x) % 2 != 0:
				return 1
		return 2
	else:
		for x in Breach:
			if int(x) % 2 == 0:
				return 2
		return 1
t = int(input())
for _ in range(t):
	l = int(input())
	val = input()
	ans = main(val, l)
	print(ans)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = input()
		if n % 2 == 0:
			ce = 0
			for x in range(1, n, 2):
				if int(a[x]) % 2 == 0:
					ce += 1
			if ce == 0:
				print(1)
			else:
				print(2)
		else:
			co = 0
			for x in range(0, n, 2):
				if int(a[x]) % 2 != 0:
					co += 1
			if co == 0:
				print(2)
			else:
				print(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()


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = a[::2]
	c = a[1::2]
	if n % 2 == 0:
		for i in c:
			if int(i) % 2 == 0:
				flag = 1
				break
			else:
				flag = 0
		if flag == 1:
			print(2)
		else:
			print(1)
	else:
		for i in b:
			if int(i) % 2 != 0:
				flag = 1
				break
			else:
				flag = 0
		if flag == 1:
			print(1)
		else:
			print(2)


try:
	import math
	t = int(input())
	for i in range(0, t):
		n = int(input())
		s = input()
		s = list(s)
		c = 0
		d = 0
		e = 0
		for i in range(0, len(s)):
			if i % 2 == 0 and int(s[i]) % 2 == 1:
				c += 1
			elif i % 2 == 1 and int(s[i]) % 2 == 0:
				d += 1
			elif i % 2 == 1 and int(s[i]) % 2 == 1:
				e += 1
		if c >= 1 and n % 2 == 1:
			print(1)
		elif e == n // 2 and n % 2 == 0:
			print(1)
		else:
			print(2)
except:
	pass


import sys

def get_line():
	return list(map(int, sys.stdin.readline().strip().split()))

def in1():
	return int(input())
for _ in range(in1()):
	n = in1()
	t = list(str(int(input())))
	y = 0
	if len(t) % 2 != 0:
		for j in range(0, n, 2):
			if int(t[j]) % 2 != 0:
				y = 1
				break
		if y == 1:
			print(1)
		else:
			print(2)
	else:
		for j in range(1, n, 2):
			if int(t[j]) % 2 == 0:
				y = 1
				break
		if y == 1:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	k = list(input())
	oe = ee = oo = eo = 0
	for i in range(n):
		if i % 2 == 0:
			if int(k[i]) % 2 == 0:
				oe += 1
			else:
				oo += 1
		elif int(k[i]) % 2 == 0:
			ee += 1
		else:
			eo += 1
	if n % 2 == 0:
		if ee >= 1:
			print('2')
		else:
			print('1')
	elif oo >= 1:
		print('1')
	else:
		print('2')


t = input()
t = int(t)

def solve(n, a):
	if n % 2 == 1:
		for i in range(n):
			if i % 2 == 0:
				if int(a[i]) % 2 == 1:
					print(1)
					return
		print(2)
		return
	else:
		for i in range(n):
			if i % 2 == 1:
				if int(a[i]) % 2 == 0:
					print(2)
					return
		print(1)
		return
for i in range(t):
	n = input()
	n = int(n)
	a = input()
	solve(n, a)


for h in range(int(input())):
	n = int(input())
	s = input()
	if n % 2:
		for i in range(0, n, 2):
			if int(s[i]) % 2:
				print(1)
				break
		else:
			print(2)
	else:
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				print(2)
				break
		else:
			print(1)


t = int(input())
for turn in range(t):
	raze_turn = True if turn % 2 == 0 else False
	n = int(input())
	num = input()
	sum_odd_at_even = 0
	sum_even_at_even = 0
	sum_odd_at_odd = 0
	sum_even_at_odd = 0
	for i in range(0, n, 2):
		if int(num[i]) % 2 == 0:
			sum_even_at_odd += 1
		else:
			sum_odd_at_odd += 1
	for i in range(1, n, 2):
		if int(num[i]) % 2 == 0:
			sum_even_at_even += 1
		else:
			sum_odd_at_even += 1
	if n % 2 == 0:
		if sum_even_at_even > 0:
			print(2)
		else:
			print(1)
	elif sum_odd_at_odd > 0:
		print(1)
	else:
		print(2)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = str(input())
	if n % 2:
		flag = False
		for i in range(0, n, 2):
			if int(s[i]) % 2:
				ans = 1
				flag = True
				break
		if not flag:
			ans = 2
	else:
		flag = False
		for i in range(1, n, 2):
			if not int(s[i]) % 2:
				ans = 2
				flag = True
				break
		if not flag:
			ans = 1
	print(ans)


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	n = int(input())
	aa = [int(a) for a in input()]
	if n % 2 == 0:
		aae = aa[1::2]
		if any((a % 2 == 0 for a in aae)):
			print(2)
		else:
			print(1)
	else:
		aao = aa[0::2]
		if any((a % 2 == 1 for a in aao)):
			print(1)
		else:
			print(2)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


t = int(input())
for i in range(t):
	n = int(input())
	k = int(input())
	z = k
	c = 0
	while z > 0:
		c = c + 1
		z = z // 10
	if c % 2 == 0:
		b = 0
		while k > 0:
			if k % 2 == 0:
				b = 1
				break
			k = k // 100
	else:
		b = 1
		while k > 0:
			if k % 2 == 1:
				b = 0
				break
			k = k // 100
	print(b + 1)


x = int(input())
for i in range(x):
	a = int(input())
	b = list(input())
	ba = []
	bb = []
	for i in range(len(b)):
		if i % 2 == 0:
			ba.append(b[i])
		else:
			bb.append(b[i])
	if a % 2 == 0:
		if list(filter(lambda x: int(x) % 2 == 0, bb)):
			print(2)
		else:
			print(1)
	elif list(filter(lambda x: int(x) % 2 == 1, ba)):
		print(1)
	else:
		print(2)


import sys
from collections import deque
pprint = lambda s: print(' '.join(map(lambda x: str(x), s)))
input = lambda : sys.stdin.readline().strip()
ipnut = input
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input()))
	d = 0
	ans = [[], []]
	if n % 2:
		d = 1
	for i in range(n):
		ans[i % 2].append(a[i] % 2)
	if d:
		if 1 in ans[0]:
			print(1)
		else:
			print(2)
	elif 0 in ans[1]:
		print(2)
	else:
		print(1)


tc = int(input())
for _ in range(tc):
	n = int(input())
	digits = input()
	if n % 2 == 1:
		for i in range(0, n, 2):
			flag = False
			if int(digits[i]) % 2 == 1:
				print(1)
				flag = True
				break
		if not flag:
			print(2)
	else:
		for i in range(1, n, 2):
			flag = False
			if int(digits[i]) % 2 == 0:
				print(2)
				flag = True
				break
		if not flag:
			print(1)


import math

def range_input():
	return range(int(input()))

def map_int_input():
	return list(map(int, input().split()))
for t in range_input():
	n = int(input())
	a = input()
	a = [int(i) for i in a]
	e2 = 0
	o1 = 0
	for (idx, i) in enumerate(a):
		if (idx + 1) % 2 == 1:
			if i % 2 == 1:
				o1 += 1
		elif i % 2 == 0:
			e2 += 1
	if n % 2 == 1:
		if o1 > 0:
			print(1)
		else:
			print(2)
	elif e2 > 0:
		print(2)
	else:
		print(1)


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	s = input().strip()
	L = list(map(int, s))
	if n == 1:
		if L[0] & 1 == 1:
			print(1)
		else:
			print(2)
		return
	even = 0
	odd = 0
	x = len(L)
	if x & 1 == 0:
		for i in range(1, n, 2):
			if L[i] & 1 == 0:
				print(2)
				break
		else:
			print(1)
	else:
		for i in range(0, n, 2):
			if L[i] & 1 == 1:
				print(1)
				break
		else:
			print(2)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = list()
	for ss in s:
		a.append(int(ss))
	odd = 0
	even = 0
	for i in range(n):
		if (i + 1) % 2 == 0:
			if a[i] % 2 == 0:
				even += 1
		elif a[i] % 2 != 0:
			odd += 1
	if n % 2 == 0:
		if even > 0:
			print(2)
		else:
			print(1)
	elif odd > 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	s = input()
	odd = s[0::2]
	even = s[1::2]
	if n % 2 == 0 and set('02468') & set(even) or (n % 2 == 1 and (not set('13579') & set(odd))):
		print(2)
	else:
		print(1)


def solve(n):
	s = input()
	if n % 2 == 1:
		for i in range(0, n, 2):
			if s[i] in '13579':
				return 1
		return 2
	else:
		for i in range(1, n, 2):
			if s[i] in '02468':
				return 2
		return 1
t = int(input())
for _ in range(t):
	n = int(input())
	print(solve(n))


t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1:
		num = int(input())
		if num % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		num = input()
		num = list(map(int, str(num)))
		odd = []
		even = []
		odd_flag = 0
		even_flag = 0
		for i in range(n):
			if i % 2 == 0:
				odd.append(num[i])
				if odd_flag == 1:
					continue
				elif num[i] % 2 == 1:
					odd_flag = 1
			else:
				even.append(num[i])
				if even_flag == 1:
					pass
				elif num[i] % 2 == 0:
					even_flag = 1
		if n % 2 == 0:
			if even_flag == 1:
				print('2')
			else:
				print('1')
		elif odd_flag == 0:
			print('2')
		else:
			print('1')


from itertools import permutations
from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import *
import copy
import itertools
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')
t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	if n % 2 == 1:
		i = 0
		isPossible = False
		while i < n:
			if int(s[i]) % 2 == 1:
				isPossible = True
				print('1')
				break
			i += 2
		if isPossible == False:
			print('2')
	else:
		i = 1
		isPossible = False
		while i < n:
			if int(s[i]) % 2 == 0:
				isPossible = True
				print('2')
				break
			i += 2
		if isPossible == False:
			print('1')


tt = int(input())
while tt > 0:
	len = int(input())
	num_str = input()
	has_even = False
	has_odd = False
	for i in range(0, len):
		dump = int(num_str[i])
		if i % 2 == 0:
			if dump % 2 == 1:
				has_odd = True
		elif dump % 2 == 0:
			has_even = True
	if len % 2 == 0:
		if has_even:
			print('2')
		else:
			print('1')
	elif has_odd:
		print('1')
	else:
		print('2')
	tt -= 1


t = int(input())
for q in range(0, t):
	n = int(input())
	a = input()
	if n == 1:
		if int(a) % 2 == 0:
			print(2)
		else:
			print(1)
	elif len(a) % 2 == 0:
		ans = 1
		for i in range(1, n, 2):
			if int(a[i]) % 2 == 0:
				ans = 2
				break
		print(ans)
	else:
		ans = 2
		for i in range(0, n, 2):
			if int(a[i]) % 2 != 0:
				ans = 1
				break
		print(ans)


t = int(input())
while t:
	n = int(input())
	number = int(input())
	s = str(number)
	if n == 1 and int(s) % 2 == 0:
		print(2)
	elif n == 1 and int(s) % 2 != 0:
		print(1)
	elif n % 2 == 0 and int(s[n - 1]) % 2 == 0:
		print(2)
	elif n % 2 != 0 and int(s[n - 1]) % 2 != 0:
		print(1)
	else:
		count = -1
		if n % 2 == 0:
			for i in range(n):
				if (i + 1) % 2 == 0 and int(s[i]) % 2 == 0:
					count = 0
					print(2)
					break
			if count == -1:
				print(1)
		else:
			for i in range(n):
				if (i + 1) % 2 != 0 and int(s[i]) % 2 != 0:
					count = 0
					print(1)
					break
			if count == -1:
				print(2)
	t -= 1


t = int(input())
while t:
	t = t - 1
	n = int(input())
	dig = input()
	dig = 'x' + dig
	E = {}
	e = 96
	o = 109
	E[e] = 0
	E[o] = 0
	O = {}
	O[o] = 0
	O[e] = 0
	for i in range(1, len(dig)):
		if i % 2 == 0:
			if int(dig[i]) % 2 == 0:
				E[e] += 1
			else:
				E[o] += 1
		elif int(dig[i]) % 2 == 0:
			O[e] += 1
		else:
			O[o] += 1
	r = True
	while n > 1:
		n = n - 1
		if r:
			if O[e] > 0:
				O[e] -= 1
			else:
				O[o] -= 1
			r = False
		else:
			if E[o] > 0:
				E[o] -= 1
			else:
				E[e] -= 1
			r = True
	if O[o] + E[o] > 0:
		print(1)
	else:
		print(2)


def raze_wins(num, n):
	r = 0
	b = 0
	for i in range(n):
		if i % 2 == 0:
			if int(num[i]) % 2 != 0:
				r += 1
		elif int(num[i]) % 2 == 0:
			b += 1
	if n % 2 == 0:
		if b > 0:
			return 2
		else:
			return 1
	elif r > 0:
		return 1
	else:
		return 2
for _ in range(int(input())):
	n = int(input())
	num = list(input())
	res = raze_wins(num, n)
	print(res)


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [1] * T
for qu in range(T):
	N = int(readline())
	A = list(map(int, readline().strip()))
	Aodd = [A[i] % 2 for i in range(N) if not i & 1]
	Aeven = [A[i] % 2 for i in range(N) if i & 1]
	if len(Aodd) == len(Aeven):
		if all((a == 1 for a in Aeven)):
			continue
		else:
			Ans[qu] = 2
	elif all((a == 0 for a in Aodd)):
		Ans[qu] = 2
print('\n'.join(map(str, Ans)))


t = int(input())
for _ in range(t):
	n = int(input())
	a = input().rstrip()
	f = 0
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(a[i]) % 2 == 0:
				f = 1
				break
		if f == 1:
			print(2)
		else:
			print(1)
	else:
		for i in range(0, n, 2):
			if int(a[i]) % 2 != 0:
				f = 1
				break
		if f == 1:
			print(1)
		else:
			print(2)


def main():
	t = eval(input())
	for cas in range(t):
		n = eval(input())
		s = input()
		lens = len(s)
		(odd, even) = (0, 0)
		for i in range(lens):
			tmp = int(s[i])
			if i % 2 == 1 and tmp % 2 == 0:
				even += 1
			elif i % 2 == 0 and tmp % 2 == 1:
				odd += 1
		if n % 2 == 0:
			if even != 0:
				print(2)
			else:
				print(1)
		elif odd != 0:
			print(1)
		else:
			print(2)
main()


t = int(input())
for caseNr in range(1, t + 1):
	n = int(input())
	num = str(input())
	num = [int(i) for i in num]
	odds = 0
	evens = 0
	for (j, n) in enumerate(num):
		if n % 2 == 1 and j % 2 == 0:
			odds += 1
		if n % 2 == 0 and j % 2 == 1:
			evens += 1
	if len(num) % 2 == 1:
		if odds:
			print(1)
		else:
			print(2)
	elif evens:
		print(2)
	else:
		print(1)


import sys
import math as m

def main():
	pass

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

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def sinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def ninp():
	return map(int, sys.stdin.readline().strip().split())

def linp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(a):
	print(a)
for _ in range(iinp()):
	n = iinp()
	inp = sinp()
	evenpos = [0] * 2
	oddpos = [0] * 2
	f = 1
	ind = 1
	for c in inp:
		if ind % 2 == 0:
			if int(c) % 2 == 0:
				evenpos[0] += 1
			else:
				evenpos[1] += 1
			ind += 1
		else:
			if int(c) % 2 == 0:
				oddpos[0] += 1
			else:
				oddpos[1] += 1
			ind += 1
	while True:
		if n == 1:
			break
		if f == 1:
			if oddpos[0] != 0:
				oddpos[0] -= 1
			else:
				oddpos[1] -= 1
			f = 0
			n = n - 1
			if n == 1:
				break
		else:
			if evenpos[1] != 0:
				evenpos[1] -= 1
			else:
				evenpos[0] -= 1
			f = 1
			n = n - 1
			if n == 1:
				break
	if oddpos[0] == 1 or evenpos[0] == 1:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	num = int(input())
	temp = num
	(opos_odd, opos_even, epos_odd, epos_even) = (0, 0, 0, 0)
	check_opos = True if n % 2 != 0 else False
	while temp != 0:
		if check_opos:
			if temp % 10 % 2 == 0:
				opos_even += 1
			else:
				opos_odd += 1
			check_opos = False
		else:
			if temp % 10 % 2 == 0:
				epos_even += 1
			else:
				epos_odd += 1
			check_opos = True
		temp = temp // 10
	if n % 2 == 0:
		if epos_even >= 1:
			print(2)
		else:
			print(1)
	elif opos_odd >= 1:
		print(1)
	else:
		print(2)


n = int(input())
for i in range(n):
	f = int(input())
	l = str(input())
	o = []
	e = []
	for j in range(f):
		if j % 2 == 0:
			o.append(int(l[j]))
		else:
			e.append(int(l[j]))
	cr = 0
	cb = 0
	for j in o:
		if j % 2 == 1:
			cr += 1
	for j in e:
		if j % 2 == 0:
			cb += 1
	if len(l) % 2 == 0:
		if cb >= 1:
			print(2)
		else:
			print(1)
	if len(l) % 2 == 1:
		if cr >= 1:
			print(1)
		else:
			print(2)


t = int(input())
while t:
	n = int(input())
	num = input()
	a = [num[i:i + 1] for i in range(0, len(num), 1)]
	if n == 1:
		if int(num) % 2 == 0:
			print('2')
			t -= 1
			continue
		else:
			print('1')
			t -= 1
			continue
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(a[i]) % 2 == 0:
				print('2')
				break
			if i == n - 1:
				if int(a[i]) % 2 == 0:
					print('2')
				else:
					print('1')
	else:
		for i in range(0, n, 2):
			if int(a[i]) % 2 != 0:
				print('1')
				break
			if i == n - 1:
				if int(a[i]) % 2 != 0:
					print('1')
				else:
					print('2')
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	number = input()
	found = 0
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(number[i]) % 2 == 0:
				found = 1
				break
		if found == 1:
			print(2)
		else:
			print(1)
	else:
		for i in range(0, n, 2):
			if int(number[i]) % 2 == 1:
				found = 1
				break
		if found == 1:
			print(1)
		else:
			print(2)


from sys import stdin, stdout, setrecursionlimit
import threading

class Tail_Recursion_Optimization:

	def __init__(self, recursion_limit, stack_size):
		setrecursionlimit(recursion_limit)
		threading.stack_size(stack_size)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			n = int(R())
			s = '-' + R()
			rodd = reven = bodd = beven = 0
			for j in range(1, n + 1):
				if j % 2:
					if int(s[j]) % 2:
						rodd += 1
					else:
						reven += 1
				elif int(s[j]) % 2:
					bodd += 1
				else:
					beven += 1
			if n % 2:
				if rodd:
					ans += ['1']
				else:
					ans += ['2']
			elif beven:
				ans += ['2']
			else:
				ans += ['1']
		W('\n'.join(ans))
		return 0

def main():
	s = SOLVE()
	s.solve()
threading.Thread(target=main).start()


n = int(input())
for i in range(n):
	x = input()
	a = input()
	a.split()
	a = list(a)
	e = []
	o = []
	for i in range(len(a)):
		if (i + 1) % 2 == 0:
			e.append(int(a[i]))
		else:
			o.append(int(a[i]))
	if len(a) % 2 == 0:
		c1 = 0
		for j in range(len(e)):
			if e[j] % 2 == 0:
				c1 += 1
		if c1 > 0:
			print(2)
		else:
			print(1)
	else:
		c1 = 0
		for j in range(len(o)):
			if o[j] % 2 != 0:
				c1 += 1
		if c1 > 0:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, list(input())))
	a = l[::2]
	b = l[1::2]
	if n % 2 == 0:
		for i in b:
			if i % 2 == 0:
				ans = 2
				break
		else:
			ans = 1
	else:
		for i in a:
			if i % 2 != 0:
				ans = 1
				break
		else:
			ans = 2
	print(ans)


for i1 in range(int(input())):
	n = int(input())
	num = int(input())
	l1 = {0: 0, 1: 0}
	l2 = {0: 0, 1: 0}
	i = 0
	while num > 0:
		dig = num % 10
		dig = dig % 2
		if i % 2 == 0:
			l1[dig] += 1
		else:
			l2[dig] += 1
		i += 1
		num = num // 10
	if n % 2 == 0:
		if l1[0] > 0:
			print(2)
		else:
			print(1)
	elif l1[1] > 0:
		print(1)
	else:
		print(2)


for t in range(int(input())):
	n = int(input())
	s = input()
	of = False
	ef = False
	for i in range(n):
		si = int(s[i])
		num = i + 1
		if num % 2 == 1:
			if si % 2 == 1:
				of = True
		elif si % 2 == 0:
			ef = True
	ans = 0
	if n % 2 == 1:
		if of:
			ans = 1
		else:
			ans = 2
	elif ef:
		ans = 2
	else:
		ans = 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = input()
	r = False
	b = False
	for i in range(n):
		if i % 2 == 0:
			if int(a[i]) % 2 == 1:
				r = True
		elif int(a[i]) % 2 == 0:
			b = True
	if n % 2 == 1:
		if r:
			print(1)
		else:
			print(2)
	elif b:
		print(2)
	else:
		print(1)


for o in range(int(input())):
	n = int(input())
	s = list(input())
	p = 0
	q = 0
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2 != 0:
				p = p + 1
		elif int(s[i]) % 2 == 0:
			q = q + 1
	if n % 2 != 0:
		if p > 0:
			print(1)
		else:
			print(2)
	elif q > 0:
		print(2)
	else:
		print(1)


def main():
	n = int(input())
	lst = input()
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(lst[i]) % 2 == 0:
				print('2')
				return
		print('1')
		return
	for i in range(0, n, 2):
		if int(lst[i]) % 2 == 1:
			print('1')
			return
	print('2')
	return

def __starting_point():
	t = int(input())
	for i in range(t):
		main()
__starting_point()


import math
from decimal import *
import random
for _ in range(int(input())):
	n = int(input())
	s = str(input())
	fnd = False
	if n % 2 == 1:
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 1:
				fnd = True
				print(1)
				break
		if not fnd:
			print(2)
	else:
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				fnd = True
				print(2)
				break
		if not fnd:
			print(1)


from sys import *
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = input()
	a = []
	for i in range(n):
		a.append(int(s[i]))
	ans = 0
	if n % 2 == 0:
		ch = 0
		for i in range(1, n, 2):
			if a[i] % 2 == 0:
				ch = 2
				break
		else:
			ch = 1
		stdout.write(str(ch) + '\n')
	else:
		ch = 0
		for i in range(0, n, 2):
			if a[i] % 2 == 1:
				ch = 1
				break
		else:
			ch = 2
		stdout.write(str(ch) + '\n')


t = int(input())
for _ in range(t):
	n = int(input())
	z = input()
	o = []
	e = []
	rch = 0
	bch = 0
	for i in range(n):
		if i % 2 == 0:
			o.append(int(z[i]))
			if o[-1] % 2 == 1:
				rch = 1
		else:
			e.append(int(z[i]))
			if e[-1] % 2 == 0:
				bch = 1
	if n % 2 == 1 and rch == 1:
		print(1)
	elif n % 2 == 1 and rch == 0:
		print(2)
	elif n % 2 == 0:
		if bch == 1:
			print(2)
		else:
			print(1)


def solve(p, n):
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(p[i]) % 2 == 0:
				return 2
		return 1
	for i in range(0, n, 2):
		if int(p[i]) % 2 != 0:
			return 1
	return 2
for _ in range(int(input())):
	n = int(input())
	p = input()
	print(solve(p, n))


t = int(input())

def solve():
	n = int(input())
	sz = input()
	if n % 2 == 0:
		for x in sz[1::2]:
			if int(x) % 2 == 0:
				return 2
		return 1
	else:
		for x in sz[::2]:
			if int(x) % 2 != 0:
				return 1
		return 2
for _ in range(t):
	print(solve())


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj
import sys
import threading
from math import *
for _ in range(int(input())):
	n = int(input())
	s = list(input())
	a = [int(x) for x in s]
	(even, odd) = ([], [])
	for i in range(n):
		if i & 1 == 0:
			odd.append(a[i])
		else:
			even.append(a[i])
	(f1, f2) = (0, 0)
	for i in even:
		if i & 1 == 0:
			f1 = 1
			break
	for i in odd:
		if i & 1:
			f2 = 1
			break
	if n & 1 and f2 == 1:
		print(1)
	elif n & 1 and f2 == 0:
		print(2)
	elif n & 1 == 0 and f1 == 1:
		print(2)
	elif n & 1 == 0 and f1 == 0:
		print(1)


for _ in range(int(input())):
	a = int(input())
	number = input()
	raze = [0, 0]
	breach = [0, 0]
	count = 0
	while count < len(number):
		if count % 2 == 0:
			if int(number[count]) % 2 == 0:
				raze[1] += 1
			else:
				raze[0] += 1
		elif int(number[count]) % 2 == 0:
			breach[1] += 1
		else:
			breach[0] += 1
		count += 1
	if a % 2 == 0:
		if breach[1] == 0:
			print(1)
		else:
			print(2)
	elif raze[0] == 0:
		print(2)
	else:
		print(1)


T = int(input())
for t in range(T):
	l = int(input())
	n = input()
	if l % 2 == 0:
		ans = 1
		for i in range(1, l, 2):
			if int(n[i]) % 2 == 0:
				ans = 2
				break
	else:
		ans = 2
		for i in range(0, l, 2):
			if int(n[i]) % 2 != 0:
				ans = 1
				break
	print(ans)


def solve(n, s):
	r_odd = 0
	r_even = 0
	b_odd = 0
	b_even = 0
	for i in range(n):
		if i % 2 == 0:
			if s[i] % 2 == 0:
				r_even += 1
			else:
				r_odd += 1
		elif s[i] % 2 == 0:
			b_even += 1
		else:
			b_odd += 1
	if n % 2 == 0:
		if b_even >= 1:
			print(2)
		else:
			print(1)
	elif r_odd >= 1:
		print(1)
	else:
		print(2)
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input()))
	solve(n, s)


t = int(input())
for tt in range(t):
	n = int(input())
	s = input()
	oo = 0
	ee = 0
	for (i, ch) in enumerate(s):
		temp = int(ch)
		if temp % 2:
			if (i + 1) % 2:
				oo += 1
		elif (i + 1) % 2 == 0:
			ee += 1
	ans = None
	if n % 2:
		if oo >= 1:
			ans = '1'
		else:
			ans = '2'
	elif ee >= 1:
		ans = '2'
	else:
		ans = '1'
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	even = 0
	odd = 0
	if n % 2 == 1:
		s = s[::2]
	else:
		s = s[1::2]
	for c in s:
		if int(c) % 2 == 1:
			odd += 1
		else:
			even += 1
	if n % 2 == 1:
		if odd:
			print(1)
		else:
			print(2)
	elif even:
		print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	match = str(input())
	odd_pos = match[0::2]
	even_pos = match[1::2]
	if len(match) % 2 == 1:
		raze_win = False
		for each in odd_pos:
			if int(each) % 2 == 1:
				raze_win = True
				break
		if raze_win:
			print(1)
		else:
			print(2)
	else:
		breach_win = False
		for each in even_pos:
			if int(each) % 2 == 0 or int(each) == 0:
				breach_win = True
				break
		if breach_win:
			print(2)
		else:
			print(1)


import sys
readline = sys.stdin.readline
INF = 1 << 60

def read_int():
	return int(readline())

def read_int_n():
	return list(map(int, readline().split()))

def read_float():
	return float(readline())

def read_float_n():
	return list(map(float, readline().split()))

def read_str():
	return readline().strip()

def read_str_n():
	return readline().strip().split()

def ep(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.perf_counter()
		ret = f(*args, **kwargs)
		e = time.perf_counter()
		ep(e - s, 'sec')
		return ret
	return wrap

def slv(N, S):
	d = [[] for _ in range(2)]
	for (i, c) in enumerate(S, start=1):
		d[i % 2].append(int(c) % 2)
	p = N % 2
	d = d[p]
	if p in d:
		return (p ^ 1) + 1
	else:
		return p + 1

def main():
	for _ in range(read_int()):
		N = read_int()
		S = read_str()
		print(slv(N, S))
main()


for _ in range(int(input())):
	n = int(input())
	number = input()
	e = 0
	o = 0
	for i in range(1, n + 1):
		if int(number[i - 1]) % 2 == 0 and i % 2 == 0:
			e = 1
		if int(number[i - 1]) % 2 != 0 and i % 2 == 1:
			o = 1
	if n % 2 == 0:
		if e == 0:
			print(1)
		else:
			print(2)
	elif o == 0:
		print(2)
	else:
		print(1)


import sys
input = sys.stdin.readline
T = int(input())
for t in range(T):
	N = int(input())
	number = str(int(input()))
	if N % 2:
		for i in range(N):
			if i % 2 == 0 and int(number[i]) % 2:
				print(1)
				break
		else:
			print(2)
	else:
		for i in range(N):
			if i % 2 and int(number[i]) % 2 == 0:
				print(2)
				break
		else:
			print(1)


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, list(stdin.readline().rstrip())))
	(has_odd_in_odd, has_even_in_even) = (False, False)
	for (idx, val) in enumerate(a):
		if val % 2 == 1 and (idx + 1) % 2 == 1:
			has_odd_in_odd = True
		if val % 2 == 0 and (idx + 1) % 2 == 0:
			has_even_in_even = True
	if n % 2 == 1 and has_odd_in_odd or (n % 2 == 0 and (not has_even_in_even)):
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	odd = []
	even = []
	for i in range(n):
		if i + 1 & 1:
			odd.append(s[i])
		else:
			even.append(s[i])
	odd = list(map(int, odd))
	even = list(map(int, even))
	if n & 1:
		flag = 0
		for i in odd:
			if i & 1:
				flag = 1
				print('1')
				break
		if flag == 0:
			print('2')
	else:
		flag = 0
		for i in even:
			if i & 1 == 0:
				flag = 1
				print('2')
				break
		if flag == 0:
			print('1')


t = int(input())
for r in range(t):
	n = int(input())
	s = int(input())
	p = str(s)
	c = 0
	if n == 1:
		if s % 2 == 0:
			c = 2
		else:
			c = 1
	elif n % 2 == 1:
		for i in range(n):
			if i % 2 == 0 and int(p[i]) % 2 == 1:
				c = 1
				break
			else:
				c = 2
	else:
		for i in range(1, n, 2):
			if int(p[i]) % 2 == 0:
				c = 2
				break
			else:
				c = 1
	print(c)


def digit_game(n, m):
	string = str(m)
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(string[i]) % 2 == 0:
				return 2
		return 1
	else:
		for i in range(0, n, 2):
			if int(string[i]) % 2 != 0:
				return 1
		return 2
t = int(input())
for i in range(t):
	n = int(input())
	m = int(input())
	print(digit_game(n, m))


for _ in range(eval(input())):
	n = eval(input())
	s = input()
	(m, odd, even) = (len(s), 0, 0)
	for i in range(m):
		tmp = int(s[i])
		if i % 2 == 1 and tmp % 2 == 0:
			even += 1
		elif i % 2 == 0 and tmp % 2 == 1:
			odd += 1
	if n % 2 == 0:
		print(2 if even != 0 else 1)
	else:
		print(1 if odd != 0 else 2)


import math
c = int(input())
for i in range(c):
	a = int(input())
	st = input()
	n = 0
	c = 0
	for j in range(a):
		if j % 2 + 1 == (ord(st[j]) - 48) % 2:
			n += 1
		elif j % 2 - 1 == (ord(st[j]) - 48) % 2:
			c += 1
	if a % 2 == 1:
		if n > 0:
			print(1)
		else:
			print(2)
	elif c > 0:
		print(2)
	else:
		print(1)


import sys

def input():
	return sys.stdin.readline().rstrip('\r\n')

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

def Num():
	return int(input())

def solve():
	n = Num()
	s = input()
	if n == 1:
		if int(s) & 1:
			print(1)
		else:
			print(2)
	else:
		(odd_pos, even_pos) = (0, 0)
		for i in range(n):
			if i % 2 == 0 and int(s[i]) & 1:
				odd_pos += 1
			elif i & 1 and int(s[i]) % 2 == 0:
				even_pos += 1
		if not n & 1:
			if even_pos:
				print(2)
			else:
				print(1)
		elif odd_pos:
			print(1)
		else:
			print(2)
for _ in range(Num()):
	solve()


for t in range(int(input())):
	n = int(input())
	num = input()
	num = list(num)
	num1 = num[::2]
	num2 = num[1::2]
	if len(num1) > len(num2):
		win = 0
		for data in num1:
			if int(data) % 2 == 1:
				win = 1
				break
		if win == 1:
			print(1)
		else:
			print(2)
	else:
		win = 0
		for data in num2:
			if int(data) % 2 == 0:
				win = 1
				break
		if win == 1:
			print(2)
		else:
			print(1)


for i in range(int(input())):
	n = int(input())
	a = input()
	c = 0
	if n % 2 == 1:
		for j in range(0, n, 2):
			if int(a[j]) % 2 == 1:
				c = c + 1
				break
		if c > 0:
			print('1')
		else:
			print('2')
	else:
		for j in range(1, n, 2):
			if int(a[j]) % 2 == 0:
				c = c + 1
				break
		if c > 0:
			print('2')
		else:
			print('1')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def main():
	for i in range(ii()):
		n = ii()
		s = [int(i) for i in input()]
		if len(s) == 1:
			if s[0] % 2 == 0:
				print(2)
				continue
			else:
				print(1)
				continue
		razee = []
		razeod = []
		breache = []
		breachod = []
		for i in range(n):
			if i % 2 == 0:
				if s[i] % 2 == 0:
					razee.append(s[i])
				else:
					razeod.append(s[i])
			elif s[i] % 2 == 1:
				breachod.append(s[i])
			else:
				breache.append(s[i])
		razee.extend(razeod)
		breachod.extend(breache)
		if len(razee) > len(breachod):
			if razee[-1] % 2 == 1:
				print(1)
			else:
				print(2)
		elif breachod[-1] % 2 == 0:
			print(2)
		else:
			print(1)
main()


import math
t = int(input())
ct = []
digit = []
flag = 0
for i in range(t):
	ct.append(int(input()))
	digit.append(list(input()))
for i in range(len(digit)):
	flag = 0
	if len(digit[i]) % 2 == 0:
		for j in range(1, len(digit[i]), 2):
			if int(digit[i][j]) % 2 == 0:
				flag = 1
				print('2')
				break
		if flag == 0:
			print('1')
	else:
		for j in range(0, len(digit[i]), 2):
			if int(digit[i][j]) % 2 != 0:
				flag = 1
				print('1')
				break
		if flag == 0:
			print('2')


for _ in range(int(input())):
	n = int(input())
	a = input()
	found = False
	if n % 2 == 0:
		for i in range(n):
			if (i + 1) % 2 == 0 and int(a[i]) % 2 == 0:
				print(2)
				found = True
				break
		if not found:
			print(1)
	else:
		for i in range(n):
			if (i + 1) % 2 != 0 and int(a[i]) % 2 != 0:
				print(1)
				found = True
				break
		if not found:
			print(2)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def solve():
	for _ in range(ii()):
		n = ii()
		s = si()
		(c1o, c1e, c2o, c2e) = (0, 0, 0, 0)
		for i in range(n):
			if i % 2 == 0:
				if int(s[i]) & 1:
					c1o += 1
				else:
					c1e += 1
			elif int(s[i]) & 1:
				c2o += 1
			else:
				c2e += 1
		if n & 1:
			if c1o > 0:
				print(1)
			else:
				print(2)
		elif c2e > 0:
			print(2)
		else:
			print(1)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
solve()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input()))
	odd_at_even_pos = 0
	even_at_odd_pos = 0
	even = 0
	odd = 0
	for (i, ele) in enumerate(arr):
		if (i + 1) % 2 == 0:
			if ele % 2 == 1:
				odd_at_even_pos += 1
				odd += 1
			else:
				even += 1
		elif ele % 2 == 0:
			even_at_odd_pos += 1
			even += 1
		else:
			odd += 1
	turn = True
	while True:
		if odd == 0:
			print(2)
			break
		elif even == 0:
			print(1)
			break
		if turn:
			if even_at_odd_pos > 0:
				even_at_odd_pos -= 1
				even -= 1
			else:
				odd -= 1
		elif odd_at_even_pos > 0:
			odd_at_even_pos -= 1
			odd -= 1
		else:
			even -= 1
		turn = not turn


import sys, collections, math

def in_out():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	n = int(input())
	num = str(int(input()))
	(Aodd, Aeven) = (0, 0)
	(Bodd, Beven) = (0, 0)
	for (i, ele) in enumerate(num):
		i += 1
		if int(ele) % 2 == 0:
			if i % 2 != 0:
				Aeven += 1
			else:
				Beven += 1
		elif i % 2 != 0:
			Aodd += 1
		else:
			Bodd += 1
	moveA = n // 2
	moveB = n - 1 - n // 2
	while Aeven > 0 and moveA > 0:
		Aeven -= 1
		moveA -= 1
	while Aodd > 0 and moveA > 0:
		Aodd -= 1
		moveA -= 1
	while Bodd > 0 and moveB > 0:
		Bodd -= 1
		moveB -= 1
	while Beven > 0 and moveB > 0:
		Beven -= 1
		moveB -= 1
	if Aeven > 0 or Beven > 0:
		print(2)
	elif Bodd > 0 or Aodd > 0:
		print(1)


def solve():
	n = int(input())
	s = [int(v) for v in input()]
	(re, ro) = (0, 0)
	(be, bo) = (0, 0)
	for i in range(n):
		if i % 2 == 0:
			if s[i] % 2 == 0:
				re += 1
			else:
				ro += 1
		elif s[i] % 2 == 0:
			be += 1
		else:
			bo += 1
	for i in range(n - 1):
		if i % 2 == 0:
			if re:
				re -= 1
			else:
				ro -= 1
		elif bo:
			bo -= 1
		else:
			be -= 1
	if n % 2 == 0:
		if bo:
			print(1)
		else:
			print(2)
	elif ro:
		print(1)
	else:
		print(2)
t = int(input())
for _ in range(t):
	solve()


for i in range(int(input())):
	n = int(input())
	z = int(input())
	s = str(z)
	if n == 1:
		if z % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		for i in range(n):
			if i % 2 != 0:
				if int(s[i]) % 2 == 0:
					print(2)
					break
		else:
			print(1)
	else:
		for i in range(n):
			if i % 2 == 0:
				if int(s[i]) % 2 != 0:
					print(1)
					break
		else:
			print(2)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
from itertools import accumulate
from functools import lru_cache
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	s = st()
	raze = breach = 0
	for (ind, i) in enumerate(s):
		num = int(i)
		if ind & 1:
			if num & 1 == 0:
				breach = 1
		elif num & 1:
			raze = 1
	if n & 1:
		print(1 if raze else 2)
	else:
		print(2 if breach else 1)


for _ in range(int(input())):
	n = int(input())
	s = [int(e) for e in input()]
	even_od = 0
	even_even = 0
	od_od = 0
	od_even = 0
	for i in range(0, n):
		if i % 2 == 0:
			if s[i] % 2 == 0:
				even_even += 1
			else:
				even_od += 1
		elif s[i] % 2 == 0:
			od_even += 1
		else:
			od_od += 1
	if n & 1 != 0:
		if even_od > 0:
			print(1)
		else:
			print(2)
	elif od_even > 0:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = input()
	p = []
	for i in range(0, len(a)):
		p.append(int(a[i]))
	if n % 2 == 0:
		even = 0
		for i in range(0, len(p)):
			if (i + 1) % 2 == 0 and p[i] % 2 == 0:
				even = 1
				break
		if even == 1:
			print(2)
		else:
			print(1)
	else:
		odd = 0
		for i in range(0, len(p)):
			if (i + 1) % 2 != 0 and p[i] % 2 != 0:
				odd = 1
				break
		if odd == 1:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input()))
	if n % 2:
		o = 0
		for i in range(0, n, 2):
			if a[i] % 2:
				o = 1
				break
		if o:
			print(1)
		else:
			print(2)
	else:
		e = 0
		for i in range(1, n, 2):
			if a[i] % 2 == 0:
				e = 1
				break
		if e:
			print(2)
		else:
			print(1)


import heapq as hq
from heapq import heappop, heappush
from collections import deque, defaultdict, Counter
from sys import stdin, stdout

def inp():
	return int(stdin.readline())

def inlt():
	return list(map(int, stdin.readline().split()))

def insr():
	return list(stdin.readline().strip())

def invr():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def subset_sum_count(arr, n, sum):
	dp = [[0 for _ in range(sum + 1)] for _ in range(n + 1)]
	for i in range(n + 1):
		for j in range(sum + 1):
			if j == 0:
				dp[i][j] = 1
			elif arr[i - 1] <= j:
				dp[i][j] = dp[i - 1][j - arr[i - 1]] + dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j]
	return dp[n][sum]

def binary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		mi = lo + (hi - lo) / 2
		if func(mi):
			hi = mi
		else:
			lo = mi
	return (lo + hi) / 2

def ternary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		lo_third = lo + (hi - lo) / 3
		hi_third = hi - (hi - lo) / 3
		if func(lo_third) < func(hi_third):
			lo = lo_third
		else:
			hi = hi_third
	return (lo + hi) / 2

def discrete_binary_search(func, lo, hi):
	while lo < hi:
		mi = lo + (hi - lo) // 2
		if func(mi):
			hi = mi
		else:
			lo = mi + 1
	return lo

def discrete_ternary_search(func, lo, hi):
	while lo <= hi:
		lo_third = lo + (hi - lo) // 3
		hi_third = lo + (hi - lo) // 3 + (1 if 0 < hi - lo < 3 else (hi - lo) // 3)
		if func(lo_third) < func(hi_third):
			lo = lo_third + 1
		else:
			hi = hi_third - 1
	return lo
	return -1

def right_rotate(a, s):
	return a[s:] + a[:s]

def dec_to_bin(x):
	return int(bin(x)[2:])

def str_to_integer_list(n):
	a = []
	for i in range(len(n)):
		a.append(int(n[i]))
	return a

def list_to_str(l):
	s = ''
	for i in l:
		s += str(i)
	return s

def dijkstra(s, N, E):
	visited = set()
	dist = {}
	for i in range(1, N + 1):
		dist[i] = 1 << 29
	queue = [(dist[i], i) for i in range(1, N + 1)]
	hq.heappush(queue, (0, s))
	dist[s] = 0
	while queue:
		(d, u) = hq.heappop(queue)
		if u in visited:
			continue
		for t in E[u]:
			(v, r) = t
			if dist[v] > d + r:
				dist[v] = d + r
				hq.heappush(queue, (dist[v], v))
		visited.add(u)
	return dist

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def dijkstra(n, graph, start):
	(dist, parents) = ([float('inf')] * n, [-1] * n)
	dist[start] = 0
	queue = [(0, start)]
	while queue:
		(path_len, v) = heappop(queue)
		if path_len == dist[v]:
			for (w, edge_len) in graph[v]:
				if edge_len + path_len < dist[w]:
					(dist[w], parents[w]) = (edge_len + path_len, v)
					heappush(queue, (edge_len + path_len, w))
	return (dist, parents)

def path(start, end, parent):
	path = [end]
	while path[-1] != start:
		path.append(parent[path[-1]])
	path.reverse()
	return path

def bfs(graph, start, goal):
	if start == goal:
		return [start]
	visited = {start}
	queue = deque([(start, [])])
	while queue:
		(current, path) = queue.popleft()
		visited.add(current)
		for neighbor in graph[current]:
			if neighbor == goal:
				return path + [current, neighbor]
			if neighbor in visited:
				continue
			queue.append((neighbor, path + [current]))
			visited.add(neighbor)
	return None

def fillPrefixSum(arr, n, prefixSum):
	prefixSum[0] = arr[0]
	for i in range(1, n):
		prefixSum[i] = prefixSum[i - 1] + arr[i]

def check(a, ind, d1):
	beg = a[:ind + 1]
	end = a[ind + 1:]
	d = []
	c = 0
	for i in end:
		if i - d1 in beg:
			c += 1
	return c
import os
import sys
from io import BytesIO, IOBase

def DecimalToBinary(n):

	def helper(n):
		if n == 0:
			return ''
		else:
			if n % 2 == 1:
				binaryDigit = '1'
			else:
				binaryDigit = '0'
			return helper(n // 2) + binaryDigit
	if n == 0:
		result = '0'
	else:
		result = helper(n)
	return result

def p(board):
	for i in range(8):
		s = ''
		for j in range(8):
			s += board[i][j]
		print(s)

def binaryToDecimal(n):
	return int(n, 2)

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

def solve(a, b):
	x = DecimalToBinary(a)
	y = DecimalToBinary(b)
	z = x + y
	l = y + x
	r = binaryToDecimal(z) - binaryToDecimal(l)
	return r

def mostFrequent(arr, n):
	arr.sort()
	max_count = 1
	res = arr[0]
	curr_count = 1
	for i in range(1, n):
		if arr[i] == arr[i - 1]:
			curr_count += 1
		else:
			if curr_count > max_count:
				max_count = curr_count
				res = arr[i - 1]
			curr_count = 1
	if curr_count > max_count:
		max_count = curr_count
		res = arr[n - 1]
	return res
from bisect import bisect_right, bisect_left

def lds(arr, n):
	lds = [0] * n
	max = 0
	for i in range(n):
		lds[i] = 1
	for i in range(1, n):
		for j in range(i):
			if arr[i] < arr[j] and lds[i] < lds[j] + 1:
				lds[i] = lds[j] + 1
	for i in range(n):
		if max < lds[i]:
			max = lds[i]
	return max
import math

def prefix(a):
	pre = []
	pre.append(a[0])
	for i in range(1, len(a)):
		pre.append(pre[i - 1] + a[i])
	return pre

def solve(n, x, size):
	res = 10000000
	if n == 0:
		return 0
	if size == 0:
		return 0
	for i in x:
		res = 1 + min(res, solve(n - i, x, size - 1))
		return res

def main():
	for _ in range(inp()):
		digits = inp()
		n = str(inp())
		x = str_to_integer_list(n)
		n = int(n)
		if digits == 1:
			if n % 2 == 0:
				pr(2)
			else:
				pr(1)
		elif digits % 2 == 1:
			f = 0
			for i in range(0, digits, 2):
				if x[i] % 2 == 1:
					f = 1
					break
			if f == 1:
				pr(1)
			else:
				pr(2)
		else:
			f = 0
			for i in range(1, digits, 2):
				if x[i] % 2 == 0:
					f = 1
					break
			if f == 1:
				pr(2)
			else:
				pr(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()


for _ in range(int(input())):
	n = int(input())
	s = input()
	if n & 1:
		o = 0
		for i in range(0, n, 2):
			if int(s[i]) & 1 != 0:
				o += 1
		if o >= 1:
			print(1)
		else:
			print(2)
	else:
		e = 0
		for i in range(1, n, 2):
			if int(s[i]) & 1 == 0:
				e += 1
		if e >= 1:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	a = input()
	if n % 2 == 1:
		f = 0
		for i in range(0, n, 2):
			if int(a[i]) % 2 == 1:
				f = 1
		if f:
			print(1)
		else:
			print(2)
	else:
		f = 0
		for i in range(1, n, 2):
			if int(a[i]) % 2 == 0:
				f = 1
		if f:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input()))
	a = [x[i] for i in range(n) if i % 2 == 0]
	b = [x[i] for i in range(n) if i % 2 == 1]
	if n % 2 == 1:
		if all((i % 2 == 0 for i in a)):
			print(2)
		else:
			print(1)
	elif all((i % 2 == 1 for i in b)):
		print(1)
	else:
		print(2)


import os
import sys
from io import BytesIO, IOBase
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')
from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	for _ in range(N()):
		num = N()
		n = N()

		def c(pos):
			now = n // 10 ** (num - pos - 1) % 10
			return now
		if num % 2 == 0:
			for i in range(1, num, 2):
				if c(i) % 2 == 0:
					print(2)
					break
			else:
				print(1)
		else:
			for i in range(0, num, 2):
				if c(i) % 2 == 1:
					print(1)
					break
			else:
				print(2)
main()


from sys import stdout, stdin
from collections import defaultdict, deque
import math
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	s = input()
	if n % 2 == 0:
		flag = False
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				flag = True
				break
		if flag:
			print('2')
		else:
			print('1')
	else:
		flag = False
		for i in range(0, n, 2):
			if int(s[i]) % 2 != 0:
				flag = True
				break
		if flag:
			print('1')
		else:
			print('2')


from collections import defaultdict
import sys
import math
import random

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	s = list(input())
	if n % 2:
		win = 2
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 1:
				win = 1
				break
	else:
		win = 1
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				win = 2
				break
	print(win)


for _ in range(int(input())):
	n = int(input())
	s = input()
	if n % 2 == 0:
		flag = True
		for i in range(n):
			if int(s[i]) % 2 == 0 and i % 2 != 0:
				flag = False
				break
		if flag:
			print(1)
		else:
			print(2)
	else:
		flag = True
		for i in range(n):
			if int(s[i]) % 2 != 0 and i % 2 == 0:
				flag = False
				break
		if flag:
			print('2')
		else:
			print('1')


try:
	t = int(input())
	for i in range(t):
		l = int(input())
		n = input()
		ch = list(n)
		if l % 2 == 0:
			for x in range(1, l, 2):
				if int(ch[x]) % 2 == 0:
					print(2)
					break
			else:
				print(1)
		else:
			for x in range(0, l, 2):
				if int(ch[x]) % 2 != 0:
					print(1)
					break
			else:
				print(2)
except:
	pass


t = int(input())
while t:
	t = t - 1
	n = int(input())
	s = input()
	m = list(map(int, str(s)))
	if n % 2:
		for i in range(len(m)):
			if m[i] % 2 == 1 and i % 2 == 0:
				cnt = 1
				break
		else:
			cnt = 2
	else:
		for i in range(len(m)):
			if m[i] % 2 == 0 and i % 2 == 1:
				cnt = 2
				break
		else:
			cnt = 1
	print(cnt)


import math
import sys

def dict_sort(ans):
	ans = sorted(ans.items(), reverse=True, key=lambda kv: kv[1])

def is_prime(n):
	if n == 1:
		return 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def seive_primes(n):
	flag = [0] * (n + 10)
	flag[1] = flag[0] = 1
	i = 2
	while i * i <= n + 1:
		if flag[i] == 0:
			j = i * i
			while j <= n + 1:
				flag[j] = 1
				j += i
		i += 1
	return flag

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def alphabates():
	return 'abcdefghijklmnopqrstuvwxyz'

def binary_search(ls, n, flag):
	low = 0
	hi = n - 1
	while low <= hi:
		mid = (low + hi) // 2
		if ls[mid] == flag:
			return mid
		elif ls[mid] > flag:
			hi = mid - 1
		else:
			low = mid + 1
	return -1

def qdrt(x, a, b, c):
	return a * x * x + b * x + c

def inp():
	ls = list(map(int, input().split()))
	return ls

def mult_inp():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(input())
	flag = 0
	if n % 2 == 0:
		for i in range(n):
			if i % 2 == 1 and int(a[i]) % 2 == 0:
				flag = 1
				break
		if flag == 1:
			print(2)
		else:
			print(1)
	else:
		for i in range(n):
			if i % 2 == 0 and int(a[i]) % 2 == 1:
				flag = 1
				break
		if flag == 1:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(t):
	n = int(input())
	num = input()
	str = list()
	for i in num:
		str.append(int(i))
	if n % 2 == 1:
		for i in range(n):
			if str[i] % 2 == 1 and i % 2 == 0:
				print('1')
				break
		else:
			print('2')
	if n % 2 == 0:
		for i in range(n):
			if i % 2 == 1 and str[i] % 2 == 0:
				print('2')
				break
		else:
			print('1')


for _ in range(int(input())):
	n = int(input().strip())
	dig = input().strip()
	dig = list(dig)
	if n == 1:
		if int(dig[0]) % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		evcnt = 0
		odcnt = 0
		for i in range(1, n, 2):
			if int(dig[i]) % 2 == 0:
				evcnt += 1
			else:
				odcnt += 1
		if evcnt >= 1:
			print(2)
		else:
			print(1)
	else:
		evcnt = 0
		odcnt = 0
		for i in range(0, n, 2):
			if int(dig[i]) % 2 == 0:
				evcnt += 1
			else:
				odcnt += 1
		if odcnt >= 1:
			print(1)
		else:
			print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	number = str(input())
	if n % 2 == 0:
		if max([int(digit) % 2 == 0 for digit in number[1::2]]):
			print(2)
		else:
			print(1)
	elif n % 2 != 0:
		if max([int(digit) % 2 != 0 for digit in number[0::2]]):
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	l = int(input())
	s = input()
	if l == 1:
		if int(s) & 1:
			print(1)
		else:
			print(2)
		continue
	cod = 0
	cevn = 0
	dod = 0
	devn = 0
	for i in range(l):
		if i & 1 == 0:
			if int(s[i]) & 1:
				cod += 1
			else:
				cevn += 1
		elif int(s[i]) & 1:
			dod += 1
		else:
			devn += 1
	if l & 1:
		if cod >= 1:
			print(1)
		else:
			print(2)
	elif devn >= 1:
		print(2)
	else:
		print(1)


def a(l):
	odd = 0
	even = 0
	for x in l:
		if x % 2 == 1:
			odd += 1
		else:
			even += 1
	return (odd, even)
T = int(input())
for _ in range(T):
	n = int(input())
	l = list(map(int, list(input())))
	odds = l[::2]
	evens = l[1::2]
	if n % 2 == 1:
		(x, y) = a(odds)
		print(1 if x > 0 else 2)
	else:
		(x, y) = a(evens)
		print(2 if y > 0 else 1)


def solve():
	a = int(input())
	n = input()
	if a % 2 == 1:
		has_odd = False
		x = 0
		while x < a:
			if int(n[x]) % 2 == 1:
				has_odd = True
				break
			x += 2
		if has_odd:
			print(1)
		else:
			print(2)
	else:
		even = False
		x = 1
		while x < a:
			if int(n[x]) % 2 == 0:
				even = True
				break
			else:
				x += 2
		if even:
			print(2)
		else:
			print(1)
t = int(input())
while t > 0:
	solve()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	s = str(input())
	odd_even = 0
	even_odd = 0
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2 == 0:
				odd_even += 1
		elif int(s[i]) % 2 == 1:
			even_odd += 1
	if n % 2 == 1:
		r = n // 2
		if odd_even - r > 0:
			print(2)
		else:
			print(1)
	else:
		b = n // 2 - 1
		if even_odd - b > 0:
			print(1)
		else:
			print(2)


t = int(input())
while t:
	k = input()
	n = int(input())
	eatodd = []
	oatodd = []
	eateven = []
	oateven = []
	m = str(n)
	for i in range(len(m)):
		if i % 2 == 0:
			if int(m[i]) % 2 == 0:
				eatodd.append(int(m[i]))
			else:
				oatodd.append(int(m[i]))
		elif int(m[i]) % 2 != 0:
			oateven.append(int(m[i]))
		else:
			eateven.append(int(m[i]))
	if len(m) % 2 == 1:
		if len(oatodd) != 0:
			print(1)
		else:
			print(2)
	elif len(eateven) != 0:
		print(2)
	else:
		print(1)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	x = 1 if n % 2 == 0 else 0
	s = [int(j) for (i, j) in enumerate(list(input())) if i % 2 == x]
	if x == 0:
		k_win = False
		for k in s:
			if k % 2 == 1:
				k_win = True
				break
	else:
		k_win = True
		for k in s:
			if k % 2 == 0:
				k_win = False
				break
	print(1 if k_win else 2)


t = int(input())
h = 1
while h <= t:
	n = int(input())
	m = input()
	k = 0
	raze = []
	breach = []
	for i in range(n - 1, -1, -1):
		if i % 2 != 0:
			breach.append(int(m[i]))
		else:
			raze.append(int(m[i]))
	z = 0
	if len(raze) > len(breach):
		for i in raze:
			if i % 2 != 0:
				print('1')
				z = 1
				break
		if z == 0:
			print('2')
	elif len(raze) == len(breach):
		y = 0
		for i in breach:
			if i % 2 != 0:
				y += 1
		if len(breach) == y:
			print('1')
		else:
			print('2')
	h += 1


def solve(n, s):
	if n % 2:
		for i in range(0, n, 2):
			if int(s[i]) % 2:
				return 1
		return 2
	else:
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				return 2
		return 1
N = int(input())
for i in range(N):
	n = int(input())
	s = input()
	print(solve(n, s))


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	if n % 2 == 0:
		val = False
		for i in range(n):
			if i % 2 != 0:
				temp = int(s[i])
				if temp % 2 == 0:
					val = True
		if val:
			print(2)
		else:
			print(1)
	else:
		val = False
		for i in range(n):
			if i % 2 == 0:
				temp = int(s[i])
				if temp % 2 != 0:
					val = True
		if val:
			print(1)
		else:
			print(2)


import sys, math
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def solve():
	N = getInt()
	X = getInt()
	if N == 1:
		if X % 2 == 0:
			return 2
		return 1
	A = [int(s) for s in str(X)]
	if N % 2 == 0:
		for j in range(1, len(A), 2):
			if A[j] % 2 == 0:
				return 2
		return 1
	for j in range(0, len(A), 2):
		if A[j] % 2 == 1:
			return 1
	return 2
T = getInt()
for t in range(T):
	print(solve())


a = int(input())
for i in range(a):
	b = int(input())
	c = str(input())
	if b % 2 == 1:
		g = False
		for k in range(0, b, 2):
			if int(c[k]) % 2 == 1:
				g = True
				break
		if g == True:
			print(1)
		else:
			print(2)
	else:
		g = False
		for k in range(1, b, 2):
			if int(c[k]) % 2 == 0:
				g = True
				break
		if g == True:
			print(2)
		else:
			print(1)


t = int(input())
l = [1 for i in range(t)]

def is_odd(x):
	if x % 2 == 0:
		return 2
	else:
		return 1

def f(x):
	y = list(map(int, list(x)))
	n = len(y)
	if n == 1:
		return is_odd(y[0])
	elif n % 2 == 0:
		k = 1
		while k < n:
			if y[k] % 2 == 0:
				return 2
			k += 2
		return 1
	else:
		k = 0
		while k < n:
			if y[k] % 2 == 1:
				return 1
			k += 2
		return 2
l = []
for i in range(t):
	y = input()
	x = input()
	l.append(f(x))
for i in range(t):
	print(l[i])


for i in range(int(input())):
	n = int(input())
	x = input()
	if n % 2 == 0:
		for j in range(1, n, 2):
			if int(x[j]) % 2 == 0:
				print(2)
				break
		else:
			print(1)
	else:
		for j in range(0, n, 2):
			if int(x[j]) % 2 == 1:
				print(1)
				break
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	num = input()
	if n % 2 == 0:
		for i in range(1, n, 2):
			flag = 0
			if int(num[i]) % 2 == 0:
				print('2')
				flag = 1
				break
			else:
				pass
		if flag == 0:
			print('1')
	else:
		for i in range(0, n, 2):
			flag = 0
			if int(num[i]) % 2 != 0:
				print('1')
				flag = 1
				break
			else:
				pass
		if flag == 0:
			print('2')


def solve():
	n = int(input())
	aa = input()
	a = [0] * n
	for i in range(n):
		a[i] = int(aa[i])
	if n == 1:
		if a[0] & 1:
			return True
		return False
	if n & 1:
		for i in range(0, n, 2):
			if a[i] & 1:
				return True
		return False
	else:
		for i in range(1, n, 2):
			if a[i] % 2 == 0:
				return False
		return True
for _ in range(int(input())):
	if solve():
		print(1)
	else:
		print(2)


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	n = int(ii())
	m = ii()
	(k, k1) = (0, 0)
	for i in range(n):
		if i % 2 == 0:
			if int(m[i]) % 2 == 1:
				k += 1
		elif int(m[i]) % 2 == 0:
			k1 += 1
	if n % 2 == 0:
		if k1:
			print(2)
		else:
			print(1)
	elif k:
		print(1)
	else:
		print(2)
	return
for t in range(int(ii())):
	solve()


for s in [*open(0)][2::2]:
	if len(s) % 2:
		print('12'[any((int(i) % 2 < 1 for i in s[1:-1:2]))])
	else:
		print('21'[any((int(i) % 2 for i in s[:-1:2]))])


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil, pi, sin, cos, acos, atan
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	n = ip()
	s = ips()
	arr = [int(i) for i in s]
	if len(arr) % 2 == 0:
		breach = False
		for i in range(n):
			if i % 2 == 1:
				if arr[i] % 2 == 0:
					breach = True
					break
		if breach:
			out(2)
		else:
			out(1)
	else:
		raze = False
		for i in range(n):
			if i % 2 == 0:
				if arr[i] % 2 == 1:
					raze = True
					break
		if raze:
			out(1)
		else:
			out(2)


T = int(input())
while T > 0:
	n = int(input())
	arr = input()
	if n % 2 == 0:
		has = False
		for i in range(1, n, 2):
			if int(arr[i]) % 2 == 0:
				has = True
				break
		if has is True:
			print(2)
		else:
			print(1)
	else:
		has = False
		for i in range(0, n, 2):
			if int(arr[i]) % 2 == 1:
				has = True
				break
		if has is True:
			print(1)
		else:
			print(2)
	T -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	if len(s) % 2 == 1:
		yep = 0
		for i in range(0, len(s), 2):
			if int(s[i]) % 2 == 1:
				yep = 1
				break
		if yep:
			print(1)
		else:
			print(2)
	else:
		yep = 0
		for i in range(1, len(s), 2):
			if int(s[i]) % 2 == 0:
				yep = 1
				break
		if yep:
			print(2)
		else:
			print(1)


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	flag = 0
	flag1 = 0
	for j in range(n):
		if j & 1 and int(s[j]) % 2 == 0:
			flag = 1
		if j % 2 == 0 and int(s[j]) & 1:
			flag1 = 1
	if n % 2 == 0:
		if flag == 1:
			print(2)
		else:
			print(1)
	elif flag1 == 1:
		print(1)
	else:
		print(2)


import collections
import sys
input = sys.stdin.readline
deque = collections.deque
T = int(input())
for _ in range(T):
	n = int(input())
	num = input().rstrip()
	if n % 2 == 0:
		flag = False
		for (idx, c) in enumerate(num):
			if (idx + 1) % 2 != 0:
				continue
			if int(c) % 2 == 0:
				flag = True
				break
		if flag:
			print(2)
		else:
			print(1)
	else:
		flag = False
		for (idx, c) in enumerate(num):
			if (idx + 1) % 2 == 0:
				continue
			if int(c) % 2 != 0:
				flag = True
				break
		if flag:
			print(1)
		else:
			print(2)


import sys
import math

def scan(input_type='int'):
	if input_type == 'int':
		return list(map(int, sys.stdin.readline().strip().split()))
	else:
		return list(map(str, sys.stdin.readline().strip()))

def solution():
	for _ in range(int(input())):
		n = int(input())
		m = input()
		a = m[::2]
		b = m[1::2]
		if n % 2 == 0:
			for i in b:
				if int(i) % 2 == 0:
					b = -1
					break
			if b == -1:
				print(2)
			else:
				print(1)
		else:
			for i in a:
				if int(i) % 2 != 0:
					a = -1
					break
			if a == -1:
				print(1)
			else:
				print(2)
solution()


for _ in range(int(input())):
	n = int(input())
	s = input()
	raze = False
	breach = False
	for i in range(n):
		j = i + 1
		if j & 1 == 0 and int(s[i]) & 1 == 0:
			breach = True
		if j & 1 != 0 and int(s[i]) & 1 != 0:
			raze = True
	if n & 1 == 0:
		if breach:
			print(2)
		else:
			print(1)
	elif raze:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	lenN = int(input())
	N = [int(x) for x in list(input())]
	if lenN % 2 == 1:
		checker = 2
		for i in range(0, lenN, 2):
			if N[i] % 2 != 0:
				checker = 1
				break
	else:
		checker = 1
		for i in range(1, lenN, 2):
			if N[i] % 2 == 0:
				checker = 2
				break
	print(checker)


def digit_game(dig, n):
	if dig == 1:
		if int(n) % 2:
			return 1
		else:
			return 2
	if dig % 2:
		for i in range(0, dig, 2):
			if int(n[i]) % 2:
				return 1
		else:
			return 2
	else:
		for i in range(1, dig, 2):
			if int(n[i]) % 2 == 0:
				return 2
		else:
			return 1
t = int(input())
for _ in range(t):
	dig = int(input())
	n = input()
	print(digit_game(dig, n))


import sys
input = sys.stdin.readline
scan_int = lambda : int(input())
scan_string = lambda : input().rstrip()
read_list = lambda : list(read())
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	n = scan_int()
	s = list(scan_string())
	s = list(map(int, s))
	odd = 0
	for i in range(0, n, 2):
		if int(s[i]) % 2 == 1:
			odd += 1
	if n % 2 == 1 and odd > 0:
		print(1)
	elif n % 2 == 1 and odd == 0:
		print(2)
	even = 0
	for i in range(1, n, 2):
		if int(s[i]) % 2 == 0:
			even += 1
	if n % 2 == 0 and even > 0:
		print(2)
	elif n % 2 == 0 and even == 0:
		print(1)
for _ in range(int(input())):
	solve()


from sys import stdin, stdout
from collections import deque
import bisect
from heapq import heapify, heappop, heappush
R = lambda : stdin.readline().strip()
RL = lambda f=None: list(map(f, R().split(' '))) if f else list(R().split(' '))
output = lambda x: stdout.write(str(x) + '\n')
output_list = lambda x: output(' '.join(map(str, x)))
T = int(R())
for _ in range(T):
	n = int(input())
	num = input()
	odd = 0
	even = 0
	for i in range(1, n + 1):
		if i % 2:
			if int(num[i - 1]) % 2:
				odd = 1
		elif int(num[i - 1]) % 2 == 0:
			even = 1
	if n % 2 == 0:
		if even == 1:
			print(2)
		else:
			print(1)
	elif odd == 1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	s = input().strip()
	r = []
	b = []
	for i in range(0, n):
		l = int(s[i])
		if i % 2 == 0:
			r.append(l % 2)
		else:
			b.append(l % 2)
	if n % 2 == 0:
		if min(b) == 0:
			print(2)
		else:
			print(1)
	elif max(r) == 1:
		print(1)
	else:
		print(2)


n = int(input())
for _ in range(n):
	t = int(input())
	num = input()
	f = False
	if t % 2 != 0:
		for i in num[::2]:
			if int(i) % 2 != 0:
				print(1)
				f = True
				break
		if not f:
			print(2)
	else:
		for i in num[1::2]:
			if int(i) % 2 == 0:
				print(2)
				f = True
				break
		if not f:
			print(1)


for i in range(int(input())):
	aa = int(input())
	a = input()
	for i in range(1 - aa % 2, aa, 2):
		b = 1 + aa % 2
		if int(a[i]) % 2 == aa % 2:
			b += 1
			break
	print(2 if b == 2 else 1)


testCases = int(input())
for _ in range(testCases):
	n = int(input())
	number = str(input())
	raze = []
	breach = []
	for i in range(len(number)):
		if (i + 1) % 2 == 0:
			if int(number[i]) % 2 == 0:
				breach.append(int(number[i]))
			else:
				breach.insert(0, int(number[i]))
		elif int(number[i]) % 2 == 0:
			raze.insert(0, int(number[i]))
		else:
			raze.append(int(number[i]))
	if len(raze) > len(breach):
		if raze[len(raze) - 1] % 2 == 0:
			print(2)
		else:
			print(1)
	elif len(raze) <= len(breach):
		if breach[len(breach) - 1] % 2 == 0:
			print(2)
		else:
			print(1)


import sys
import math as mt
import bisect
t = int(input())

def solve():
	if n % 2 == 0:
		i = 1
		while i < n:
			if int(l[i]) % 2 == 0:
				return 2
				break
			i += 2
		return 1
	else:
		i = 0
		while i < n:
			if int(l[i]) % 2 != 0:
				return 1
			i += 2
		return 2
for _ in range(t):
	n = int(input())
	n1 = int(input())
	l = str(n1)
	print(solve())


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, list(input())))
	print(2 - (n % 2 == 1 and any((i % 2 for i in a[::2])) or (n % 2 == 0 and all((i % 2 for i in a[1::2])))))


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	if n == 1:
		if int(s) % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		(rodd, reven, bodd, beven) = (0, 0, 0, 0)
		for i in range(len(s)):
			if i % 2 == 0:
				if int(s[i]) % 2 == 0:
					reven += 1
				else:
					rodd += 1
			elif int(s[i]) % 2 == 0:
				beven += 1
			else:
				bodd += 1
		if n % 2 == 0:
			if beven > 0:
				print(2)
			else:
				print(1)
		elif rodd > 0:
			print(1)
		else:
			print(2)


get_int = lambda : int(input())
get_list = lambda : list(map(int, input().rstrip().split()))
TEST_CASES = True

def main():
	n = get_int()
	a = get_int()
	num = str(a)
	(r, b) = ({'e': 0, 'o': 0}, {'e': 0, 'o': 0})
	if n == 1:
		if a % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		for (i, ele) in enumerate(num, 1):
			if i % 2 == 0:
				if int(ele) % 2 != 0:
					b['o'] += 1
				else:
					b['e'] += 1
			elif int(ele) % 2 != 0:
				r['o'] += 1
			else:
				r['e'] += 1
		if n % 2 != 0:
			if r['o'] > 0:
				print(1)
			else:
				print(2)
		elif b['e'] > 0:
			print(2)
		else:
			print(1)
if not TEST_CASES:
	main()
else:
	[main() for _ in range(int(input()))]


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter
from pprint import pprint

def main():
	n = int(input())
	s = input()
	ans = -1
	if n % 2:
		ok = False
		for i in range(n):
			if i % 2 == 0 and int(s[i]) % 2:
				ok = True
		if ok:
			ans = 1
		else:
			ans = 2
	else:
		ok = False
		for i in range(n):
			if i % 2 == 1 and int(s[i]) % 2 == 0:
				ok = True
		if ok:
			ans = 2
		else:
			ans = 1
	print(ans)
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')
for _ in range(int(input())):
	main()


from sys import stdin, stdout
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	n = inp()
	s = inp()
	s = str(s)
	(odd, even) = (0, 0)
	for i in range(1, n + 1):
		if i & 1 and int(s[i - 1]) & 1:
			odd += 1
		if i % 2 == 0 and int(s[i - 1]) % 2 == 0:
			even += 1
	if n & 1:
		if odd:
			pr(1)
		else:
			pr(2)
	elif even:
		pr(2)
	else:
		pr(1)
for _ in range(inp()):
	solve()


t = int(input())
while t:
	t = t - 1
	n = int(input())
	s = input()
	odd = 0
	even = 0
	ee = 0
	oo = 0
	for i in range(n):
		if (i + 1) % 2 == 0 and int(s[i]) % 2 == 0:
			ee += 1
		elif (i + 1) % 2 and int(s[i]) % 2:
			oo += 1
	if n % 2 == 0:
		if ee:
			print(2)
		else:
			print(1)
	elif oo:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	numStr = input()

	def soln(numStr):
		for (i, c) in enumerate(numStr):
			if n % 2 == 0:
				if i % 2 == 1 and int(c) % 2 == 0:
					return 2
			elif i % 2 == 0 and int(c) % 2 == 1:
				return 1
		if n % 2 == 0:
			return 1
		else:
			return 2
	result = soln(numStr)
	print(result)


for _ in range(int(input())):
	n = int(input())
	s = int(input())
	if n == 1:
		if s % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 != 0:
		st = str(s)
		even = []
		odd = []
		i = 0
		while i < n:
			if int(st[i]) % 2 != 0:
				odd.append(st[i])
			else:
				even.append(st[i])
			i += 2
		if len(odd) == 0:
			print(2)
		else:
			print(1)
	else:
		st = str(s)
		even = []
		odd = []
		i = 1
		while i < n:
			if int(st[i]) % 2 != 0:
				odd.append(st[i])
			else:
				even.append(st[i])
			i += 2
		if len(even) == 0:
			print(1)
		else:
			print(2)


import math
import re
import itertools
import copy
import time
import sys
import functools

def input_linear(lamb=lambda x: int(x), seperator=' '):
	return map(lamb, input().split(seperator))

def input_array(lamb=lambda x: int(x), seperator=' '):
	return list(map(lamb, input().split(seperator)))

def input_matrix(rows, lamb=lambda x: int(x), seperator=' '):
	tmp_matrix = []
	for i in range(rows):
		tmp_matrix.append(input_array(lamb, seperator))
	return tmp_matrix

def input_graph_al_pair(vertices, lines, lamb=lambda x: int(x), seperator=' ', directional=False, remove_dup=False):
	temp_matrix = [x[:] for x in [[]] * vertices]
	if not directional:
		if not remove_dup:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				temp_matrix[ina].append(inb)
				temp_matrix[inb].append(ina)
		else:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				if inb not in temp_matrix[ina]:
					temp_matrix[ina].append(inb)
				if ina not in temp_matrix[inb]:
					temp_matrix[inb].append(ina)
		return temp_matrix
	else:
		if not remove_dup:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				temp_matrix[ina].append(inb)
		else:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				if inb not in temp_matrix[ina]:
					temp_matrix[ina].append(inb)
		return temp_matrix

def prettyp(a, typ='trash'):
	h = math.ceil(math.log(len(a), 2))
	for i in range(h):
		print(''.join(['  '] * (h - i)) + '  '.join(map(str, a[(1 << i) - 1:(1 << i + 1) - 1])))

def build_segment_t(a, lamb=lambda x, y: x + y):
	arr = [0] * len(a) + a.copy()
	for i in range(len(a) - 1, 0, -1):
		arr[i] = lamb(arr[i << 1], arr[i << 1 | 1])
	return arr

def mod_seg(a, pos, val):
	pos += len(a)
	a[pos] = val
	while pos > 1:
		a[pos >> 1] = a[pos] + a[pos ^ 1]
		pos >>= 1
for i in [*open(0)][2::2]:
	fl = 0
	if len(i) % 2 == 0:
		for j in i[::2]:
			if int(j) % 2 == 1:
				fl = 1
				break
		print([2, 1][fl])
	elif len(i) % 2 == 1:
		for j in i[1::2]:
			if int(j) % 2 == 0:
				fl = 1
				break
		print([1, 2][fl])


cases = int(input())
for t in range(cases):
	n = int(input())
	z = input()
	if n == 1:
		if int(z) % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		r = {'e': 0, 'o': 0}
		b = {'e': 0, 'o': 0}
		for i in range(n):
			v = int(z[i])
			if i % 2 == 0:
				if v % 2 == 0:
					r['e'] += 1
				else:
					r['o'] += 1
			elif v % 2 == 0:
				b['e'] += 1
			else:
				b['o'] += 1
		if n % 2 == 1:
			if r['o']:
				print(1)
			else:
				print(2)
		elif b['e']:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	a = input()
	if n % 2 == 0:
		Rodd = 0
		for i in range(1, n, 2):
			if int(a[i]) % 2 == 0:
				Rodd += 1
				break
		if Rodd == 0:
			print(1)
		else:
			print(2)
	else:
		odd = 0
		for i in range(0, n, 2):
			if int(a[i]) % 2 == 1:
				odd += 1
				break
		if odd == 0:
			print(2)
		else:
			print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, list(input())))
	if n % 2 == 0:
		f = True
		for j in range(n // 2):
			if a[2 * j + 1] % 2 == 0:
				f = False
				break
	else:
		f = False
		for j in range(n // 2 + 1):
			if a[2 * j] % 2 != 0:
				f = True
				break
	if f:
		print(1)
	else:
		print(2)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	t = int(input())
	S = input().rstrip()
	s = [int(x) for x in S]
	razeCanWin = False
	brchCanWin = False
	for (i, c) in enumerate(s):
		if i % 2 == 1:
			if c % 2 == 0:
				brchCanWin = True
		elif c % 2 == 1:
			razeCanWin = True
	if t % 2 == 1:
		print(1 if razeCanWin else 2)
	else:
		print(2 if brchCanWin else 1)


import sys
try:
	sys.stdin = open('input.txt', 'r')
except FileNotFoundError:
	pass

def next_array():
	return [int(i) for i in input().split()]

def prefix(lst):
	assert len(lst)
	pre = [lst[0]]
	for i in range(1, len(lst)):
		pre.append(lst[i] + pre[i - 1])
	return pre

def prefix_max(lst):
	assert len(lst)
	pre = [lst[0]]
	for i in range(1, len(lst)):
		pre.append(max(lst[i], pre[i - 1]))
	return pre

def solve():
	input()
	s = [int(i) for i in input()]
	if len(s) % 2 == 1:
		for i in range(0, len(s), 2):
			if s[i] % 2 == 1:
				print(1)
				return
		print(2)
	else:
		for i in range(1, len(s), 2):
			if s[i] % 2 == 0:
				print(2)
				return
		print(1)
for i in range(int(input())):
	solve()


t = int(input())
w = []
for i in range(t):
	n = int(input())
	k = str(input())
	boo = True
	if n % 2 == 0:
		i = 1
		while boo and i < n:
			if int(k[i]) % 2 == 0:
				boo = False
			i = i + 2
		if boo == True:
			w.append(1)
		else:
			w.append(2)
	else:
		i = 0
		while boo and i < n:
			if int(k[i]) % 2 == 1:
				boo = False
			i = i + 2
		if boo == True:
			w.append(2)
		else:
			w.append(1)
for i in w:
	print(i)


for i in range(int(input())):
	n = int(input())
	no = input()
	(odd, even, r, b) = (0, 0, 0, 0)
	for i in range(n):
		if i % 2 == 0:
			if int(no[i]) % 2 != 0:
				odd = odd + 1
			r = r + 1
		else:
			if int(no[i]) % 2 == 0:
				even = even + 1
			b = b + 1
	if odd == 0 and even == 0:
		if n % 2 == 0:
			print(1)
		else:
			print(2)
	elif odd == 0:
		print(2)
	elif even == 0:
		print(1)
	elif n % 2 != 0:
		print(1)
	else:
		print(2)


t = int(input())
for tc in range(t):
	n = int(input())
	num = int(input())
	arr = []
	while num > 0:
		ld = num % 10
		arr.append(ld)
		num //= 10
	arr.reverse()
	win1 = 0
	win2 = 0
	for i in range(n):
		if i % 2 == 0:
			if arr[i] % 2 != 0:
				win1 = 1
				break
	for i in range(n):
		if i % 2 != 0:
			if arr[i] % 2 == 0:
				win2 = 1
	if n % 2 == 0:
		if win2 == 1:
			ans = 2
		else:
			ans = 1
	elif win1 == 1:
		ans = 1
	else:
		ans = 2
	print(ans)


a = int(input())
for i in range(a):
	b = int(input())
	c = list(input())

	def DG(b):
		if b % 2:
			for j in range(0, b, 2):
				if int(c[j]) % 2:
					return '1'
			return '2'
		else:
			for j in range(1, b, 2):
				if not int(c[j]) % 2:
					return '2'
			return '1'
	print(DG(b))


def solve(n, a):
	if n % 2 == 1:
		for i in range(0, n, 2):
			if a[i] % 2 == 1:
				return 1
		return 2
	else:
		for i in range(1, n, 2):
			if a[i] % 2 == 0:
				return 2
		return 1
test_cases = int(input())
for _ in range(test_cases):
	n = int(input())
	a = list(map(int, list(input())))
	print(solve(n, a))


for _ in range(int(input())):
	n = int(input())
	r = [0, 0]
	b = [0, 0]
	d = [int(c) for c in input()]
	for i in range(n):
		if i % 2 == 1:
			b[d[i] % 2] += 1
		else:
			r[d[i] % 2] += 1
	turn = n % 2
	if turn == 1:
		if r[1] > 0:
			print(1)
		else:
			print(2)
	elif b[0] > 0:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	s = str(input())
	ans = -1
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				ans = 2
				break
		if ans == -1:
			ans = 1
	else:
		for i in range(0, n, 2):
			if int(s[i]) % 2 != 0:
				ans = 1
				break
		if ans == -1:
			ans = 2
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	ans = list(map(int, input()))
	x = 0
	y = 0
	z = 0
	w = 0
	for i in range(n):
		if i % 2 != 0:
			if ans[i] % 2:
				z += 1
			else:
				w += 1
		elif ans[i] % 2:
			x += 1
		else:
			y += 1
	if n % 2 == 0:
		if w >= 1:
			print(2)
		else:
			print(1)
	elif x >= 1:
		print(1)
	else:
		print(2)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	o1 = 0
	e1 = 0
	o2 = 0
	e2 = 0
	for i in range(n):
		if i % 2 == 0:
			if int(a[i]) % 2 == 0:
				e1 = 1
			else:
				o1 = 1
		elif int(a[i]) % 2 == 0:
			e2 = 1
		else:
			o2 = 1
	if n % 2 == 0:
		if e2 > 0:
			print(2)
		else:
			print(1)
	elif o1 > 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input()))[:n]
	x = []
	y = []
	f = 0
	k = 0
	if n == 1:
		if a[0] % 2 == 0:
			print('2')
		else:
			print('1')
	else:
		for i in range(len(a)):
			if i % 2 == 0:
				x.append(a[i])
			else:
				y.append(a[i])
		if n % 2 == 0:
			for i in y:
				if i % 2 == 0:
					f = 1
					break
			if f == 1:
				print('2')
			else:
				print('1')
		else:
			for i in x:
				if i % 2 != 0:
					k = 1
					break
			if k == 1:
				print('1')
			else:
				print('2')


import itertools
n = int(input())
number_of_digits = []
digit = []
op = []
even = 0
odd = 0
for i in range(0, n):
	number_of_digits.append(input())
	digit.append(input())
for (i, j) in zip(number_of_digits, digit):
	breach = []
	raze = []
	nums = list(j)
	for x in range(0, len(nums)):
		if x % 2 != 0:
			breach.append(nums[x])
		else:
			raze.append(nums[x])
	for k in range(len(nums)):
		if len(nums) == 1:
			if int(nums[0]) % 2 == 0:
				print('2')
			else:
				print('1')
			break
		for l in raze:
			even = 0
			if int(l) % 2 == 0:
				nums.remove(l)
				raze.remove(l)
				even = 1
				break
		if even == 0:
			nums.remove(raze.pop(0))
		if len(nums) == 1:
			if int(nums[0]) % 2 == 0:
				print('2')
			else:
				print('1')
			break
		for l in breach:
			odd = 0
			if int(l) % 2 != 0:
				nums.remove(l)
				breach.remove(l)
				odd = 1
				break
		if odd == 0:
			nums.remove(breach.pop(0))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = input()
	k = 0
	if len(s) % 2 == 0:
		for i in range(1, len(s), 2):
			if int(s[i]) % 2 == 0:
				k = 1
				break
		if k == 1:
			print(2)
		else:
			print(1)
	else:
		for i in range(0, len(s), 2):
			if int(s[i]) % 2 != 0:
				k = 1
				break
		if k == 1:
			print(1)
		else:
			print(2)


from sys import stdin

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
t = iinput()
while t:
	t -= 1
	n = iinput()
	d = input()
	(r, b) = ([], [])
	for i in range(n):
		if i & 1:
			b.append(int(d[i]))
		else:
			r.append(int(d[i]))
	r_odd = list(filter(lambda e: e & 1, r))
	b_even = list(filter(lambda e: e & 1 == 0, b))
	if n == 1:
		if int(d[0]) & 1:
			ans = 1
		else:
			ans = 2
	elif n & 1:
		if r_odd:
			ans = 1
		else:
			ans = 2
	elif b_even:
		ans = 2
	else:
		ans = 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(lambda x: int(x) % 2, input()))
	x = int(n % 2 == 0)
	print('212'[x + int(int(not x) in l[x::2])])


t = int(input())
ans = []
for j in range(t):
	n = int(input())
	a = input()
	f = 0
	i = 1
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(a[i]) % 2 == 0:
				f = 1
				break
		if f == 1:
			ans.append('2')
		else:
			ans.append('1')
	else:
		for i in range(0, n, 2):
			if int(a[i]) % 2 == 1:
				f = 1
				break
		if f == 1:
			ans.append('1')
		else:
			ans.append('2')
print('\n'.join(ans))


for _ in range(int(input())):
	n = int(input())
	k = input()
	if n % 2 == 0:
		for i in range(1, n, 2):
			g = int(k[i])
			if g % 2 == 0:
				print('2')
				break
		else:
			print('1')
	else:
		for i in range(0, n, 2):
			g = int(k[i])
			if g % 2 != 0:
				print('1')
				break
		else:
			print('2')


t = int(input())
for i in range(t):
	n = int(input())
	nu = list(input())
	for j in range(len(nu)):
		nu[j] = int(nu[j])
	e = []
	o = []
	for j in range(len(nu)):
		if (j + 1) % 2 == 0:
			e.append(nu[j])
		elif (j + 1) % 2 != 0:
			o.append(nu[j])
	if n % 2 != 0:
		flag = 0
		for j in o:
			if j % 2 != 0:
				flag = 1
				break
		if flag == 1:
			print(1)
		else:
			print(2)
	elif n % 2 == 0:
		flag = 0
		for j in e:
			if j % 2 == 0:
				flag = 1
				break
		if flag == 1:
			print(2)
		else:
			print(1)


import sys

def I():
	return int(sys.stdin.readline().rstrip())

def LI2():
	return list(map(int, sys.stdin.readline().rstrip()))
t = I()
for _ in range(t):
	n = I()
	S = LI2()
	R = S[::2]
	B = S[1::2]
	if n % 2 == 0:
		for b in B:
			if b % 2 == 0:
				print(2)
				break
		else:
			print(1)
	else:
		for r in R:
			if r % 2 == 1:
				print(1)
				break
		else:
			print(2)


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
for _ in range(inn()):
	n = inn()
	a = [int(x) for x in input()]
	ev = []
	od = []
	ce = 0
	co = 0
	for i in range(n):
		if (i + 1) % 2 == 0:
			ev += [a[i]]
			if a[i] % 2 == 0:
				ce += 1
		else:
			od += [a[i]]
			if a[i] % 2 == 1:
				co += 1
	if n % 2 == 1:
		if len(ev) > len(od):
			if ce > 0:
				print(2)
			else:
				print(1)
		elif co > 0:
			print(1)
		else:
			print(2)
	elif ce > 0:
		print(2)
	else:
		print(1)


from collections import *
from itertools import *

def inp():
	return int(input())

def arrinp():
	return [int(x) for x in input().split()]

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		number = input()
		if n == 1:
			if int(number) % 2 == 0:
				print(2)
			else:
				print(1)
			continue
		(odd_b, eve_b, odd_r, eve_r) = (0, 0, 0, 0)
		for i in range(n):
			if (i + 1) % 2 == 0:
				if int(number[i]) % 2 == 0:
					eve_b += 1
				else:
					odd_b += 1
			elif int(number[i]) % 2 == 0:
				eve_r += 1
			else:
				odd_r += 1
		if n % 2 == 0:
			if eve_b > 0:
				print(2)
			else:
				print(1)
		elif odd_r > 0:
			print(1)
		else:
			print(2)
main()


import os, sys
from io import BytesIO, IOBase
from sys import setrecursionlimit
import heapq
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
setrecursionlimit(100000)
mod = 1000000007

def main():
	for _ in [0] * int(input()):
		n = int(input())
		s = input()
		if n % 2:
			for c in s[::2]:
				if c in '13579':
					print(1)
					break
			else:
				print(2)
		else:
			for c in s[1::2]:
				if c in '24680':
					print(2)
					break
			else:
				print(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()


for _ in range(int(input())):
	o = False
	t = False
	n = int(input())
	nu = input()
	if n % 2 == 1:
		for i in range(0, n, 2):
			if int(nu[i]) % 2 == 1:
				o = True
				break
		if o == False:
			t = True
	else:
		for i in range(1, n, 2):
			if int(nu[i]) % 2 == 0:
				t = True
				break
		if t == False:
			o = True
	if o:
		print(1)
	else:
		print(2)


n = int(input())
for i in range(n):
	m = int(input())
	l = int(input())
	b = 10 ** m
	j = 0
	li = []
	lq = []
	c = 0
	d = 0
	while j < m:
		b = b // 10
		k = l // b
		l = l % b
		if j % 2 == 0:
			if k % 2 != 0:
				c = c + 1
			li.append(k)
		else:
			if k % 2 == 0:
				d = d + 1
			lq.append(k)
		j = j + 1
	if len(li) > len(lq):
		if c == 0:
			print('2')
		else:
			print('1')
	elif d != 0:
		print('2')
	else:
		print('1')


for _ in range(int(input())):
	n = int(input())
	arr = list(input())
	arr = list(map(int, arr))
	raze = arr[::2]
	breach = arr[1::2]
	if n % 2 == 0:
		if any((i % 2 == 0 for i in breach)):
			print(2)
		else:
			print(1)
	elif any((i % 2 == 1 for i in raze)):
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	a = input()
	arr = [int(i) for i in a]
	(odd, even) = (arr[::2], arr[1::2])
	if n % 2 != 0:
		found = False
		for i in odd:
			if i % 2 != 0:
				found = True
				break
		if found:
			print(1)
		else:
			print(2)
	else:
		found = False
		for i in even:
			if i % 2 == 0:
				found = True
				break
		if found:
			print(2)
		else:
			print(1)


def solve():
	n = int(input())
	lst = [int(i) for i in list(input())]
	if n % 2:
		for i in range(0, n, 2):
			if lst[i] % 2 == 1:
				print(1)
				return 0
		print(2)
	else:
		for i in range(1, n, 2):
			if lst[i] % 2 == 0:
				print(2)
				return 0
		print(1)
for i in range(int(input())):
	solve()


t = 0
try:
	t = int(input())
except:
	pass
n = list()
d = list()
try:
	for i in range(t):
		d.append(int(input()))
		n.append(int(input()))
except:
	pass
s = []
for i in n:
	s.append(str(i))
l = len(n)
for i in range(l):
	if d[i] % 2 == 0:
		flag = True
		for j in range(1, len(s[i]), 2):
			if int(s[i][j]) % 2 == 0:
				flag = False
				break
		if flag:
			print('1')
		else:
			print('2')
	elif d[i] % 2 == 1:
		flag = False
		for j in range(0, len(s[i]), 2):
			if int(s[i][j]) % 2 == 1:
				flag = True
				break
		if flag:
			print('1')
		else:
			print('2')


t = int(input())
for _ in range(t):
	n = int(input())
	d = input()
	c1 = 0
	c2 = 0
	for (i, j) in enumerate(d, 1):
		if i % 2 != 0 and int(j) % 2 != 0:
			c1 += 1
		if i % 2 == 0 and int(j) % 2 == 0:
			c2 += 1
		if c1 == 1 and c2 == 1:
			break
	if n % 2 == 0 and c2:
		print(2)
	elif n % 2 != 0 and c1:
		print(1)
	elif n % 2 == 0 and (not c2):
		print(1)
	elif n % 2 != 0 and (not c1):
		print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	m = input()
	m = [int(x) for x in m]
	odd_even = 0
	odd_odd = 0
	even_odd = 0
	even_even = 0
	for i in range(0, len(m), 2):
		if m[i] % 2 == 0:
			odd_even += 1
		else:
			odd_odd += 1
	for i in range(1, len(m), 2):
		if m[i] % 2 == 0:
			even_even += 1
		else:
			even_odd += 1
	if n % 2 == 1:
		if odd_odd > 0:
			print(1)
		else:
			print(2)
	elif even_even > 0:
		print(2)
	else:
		print(1)


from sys import stdin, stdout
from math import *

def main():
	t = int(stdin.readline())
	for _ in range(t):
		n = int(stdin.readline())
		number = stdin.readline().strip()
		odds = [False, False]
		evens = [False, False]
		for i in range(1, n + 1):
			if i % 2 == 0:
				if int(number[i - 1]) % 2 == 0:
					evens[1] = True
				else:
					evens[0] = True
			elif int(number[i - 1]) % 2 == 0:
				odds[1] = True
			else:
				odds[0] = True
		if n % 2 == 0:
			if evens[1]:
				print('2')
			else:
				print('1')
		elif odds[0]:
			print('1')
		else:
			print('2')
main()


t = int(input())
for i in range(t):
	n = int(input())
	N = list(input())
	(NR, NB) = ([int(N[x]) for x in range(0, n, 2)], [int(N[x]) for x in range(1, n, 2)])
	(WR, WB) = (False, False)
	i = 0
	while i < len(NR):
		if NR[i] % 2 == 1:
			WR = True
			(NR[0], NR[i]) = (NR[i], NR[0])
			break
		i += 1
	i = 0
	while i < len(NB):
		if NB[i] % 2 == 0:
			WB = True
			(NB[0], NB[i]) = (NB[i], NB[0])
			break
		i += 1
	if n % 2 == 0:
		if NB[0] % 2 == 0:
			print(2)
		else:
			print(1)
	elif len(NB) > len(NR):
		if NB[0] % 2 == 0:
			print(2)
		else:
			print(1)
	elif len(NR) > len(NB):
		if NR[0] % 2 == 0:
			print(2)
		else:
			print(1)


import sys
from sys import stdin, stdout

def get_ints():
	return list(map(float, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
n = int(input())
a = [0] * int(n)
b = [0] * int(n)
for i in range(0, n):
	a[i] = int(input())
	b[i] = int(input())
	flag = 0
	if a[i] == 1:
		if b[i] % 2 == 0:
			stdout.write('2\n')
		else:
			stdout.write('1\n')
	elif a[i] % 2 == 0:
		while b[i] > 0:
			if b[i] % 2 == 0:
				stdout.write('2\n')
				flag = 1
				break
			b[i] //= 100
		if flag == 0:
			stdout.write('1\n')
	else:
		while b[i] > 0:
			if b[i] % 2 != 0:
				stdout.write('1\n')
				flag = 1
				break
			b[i] //= 100
		if flag == 0:
			stdout.write('2\n')


n = int(input())
res = []
for i in range(n):
	game = input()
	number = input()
	if len(number) == 1:
		if int(number) % 2 == 0:
			res.append(2)
		else:
			res.append(1)
	else:
		c_c = 0
		l_l = 0
		for (i, num) in enumerate(number):
			if (i + 1) % 2 == 1 and int(num) % 2 == 1:
				l_l += 1
			elif (i + 1) % 2 == 0 and int(num) % 2 == 0:
				c_c += 1
		if len(number) % 2 == 0:
			if c_c > 0:
				res.append(2)
			else:
				res.append(1)
		elif l_l > 0:
			res.append(1)
		else:
			res.append(2)
for i in res:
	print(i)


for q in range(int(input())):
	n = int(input())
	a = input()
	print([2 if any([1 for i in range(1, n, 2) if int(a[i]) % 2 == 0]) else 1][0] if n % 2 == 0 else [1 if any([1 for i in range(0, n, 2) if int(a[i]) % 2 != 0]) else 2][0])


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input()[:-1]))
	o = 0
	e = 0
	for i in range(n):
		if i % 2 == 0 and l[i] % 2:
			o = 1
		elif i % 2 and l[i] % 2 == 0:
			e = 1
	if n % 2:
		if o == 1:
			print(1)
		else:
			print(2)
	elif e == 1:
		print(2)
	else:
		print(1)


T = int(input())
for z in range(T):
	n = int(input())
	s = input()
	if n % 2 == 0:
		count = 0
		for i in range(n):
			if (i + 1) % 2 == 0:
				e = int(s[i])
				if e % 2 != 0:
					count += 1
		if count == n // 2:
			print(1)
		else:
			print(2)
	else:
		count = 0
		for i in range(n):
			if (i + 1) % 2 != 0:
				e = int(s[i])
				if e % 2 == 0:
					count += 1
		if count == n // 2 + 1:
			print(2)
		else:
			print(1)


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
mod = 100000007
for _ in range(vary(1)):
	tt = vary(1)
	n = input()
	num = list(n)
	for i in range(len(n)):
		num[i] = int(num[i])
	z = len(n)
	if z == 1:
		if int(n) % 2 != 0:
			print(1)
			continue
		else:
			print(2)
			continue
	odd = 0
	evens = 0
	for i in range(z):
		if (i + 1) % 2 != 0 and num[i] % 2 != 0:
			odd += 1
		elif (i + 1) % 2 == 0 and num[i] % 2 == 0:
			evens += 1
	if z % 2 == 0:
		if evens != 0:
			print(2)
		else:
			print(1)
		continue
	if odd != 0:
		print(1)
	else:
		print(2)


t = int(input())
i = 0
while i < t:
	n = int(input())
	N = n
	x = int(input())
	R = 0
	B = 0
	while x > 0:
		num = x % 10
		if n % 2 == 0:
			if num % 2 == 0:
				B += 1
		elif num % 2 != 0:
			R += 1
		x //= 10
		n -= 1
	if N % 2 == 0:
		if B > 0:
			print(2)
		else:
			print(1)
	elif R > 0:
		print(1)
	else:
		print(2)
	i += 1


import sys, math, heapq, copy
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from itertools import permutations, combinations, combinations_with_replacement
mod = 1000000007

def get_int():
	return int(sys.stdin.readline().strip())

def get_str():
	return sys.stdin.readline().strip()

def get_float():
	return float(sys.stdin.readline().strip())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_strs():
	return map(str, sys.stdin.readline().strip().split())

def get_floats():
	return map(float, sys.stdin.readline().strip().split())

def list_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def list_strs():
	return list(map(str, sys.stdin.readline().strip().split()))

def list_floats():
	return list(map(float, sys.stdin.readline().strip().split()))
t = get_int()
for _ in range(t):
	n = get_int()
	num = get_str()
	if n & 1:
		flag = 2
		for i in range(0, n, 2):
			if int(num[i]) & 1:
				flag = 1
				break
		print(flag)
	else:
		flag = 1
		for i in range(1, n, 2):
			if int(num[i]) & 1 == 0:
				flag = 2
				break
		print(flag)


import math
for z in range(int(input())):
	d = int(input())
	s = input()
	flag = False
	if d % 2:
		for i in range(d):
			if i % 2 == 0 and int(s[i]) % 2:
				flag = True
				break
		if flag:
			print(1)
		else:
			print(2)
	else:
		for i in range(d):
			if i % 2 and int(s[i]) % 2 == 0:
				flag = True
				break
		if flag:
			print(2)
		else:
			print(1)


a = int(input())
for x in range(a):
	q = int(input())
	b = input()
	e = 0
	o = 0
	h = 0
	for y in b:
		if h % 2 == 0:
			if int(y) % 2 != 0:
				o += 1
		elif int(y) % 2 == 0:
			e += 1
		h += 1
	if len(b) % 2 == 0:
		if e > 0:
			print(2)
		else:
			print(1)
	elif o > 0:
		print(1)
	else:
		print(2)


from collections import Counter
for _ in range(int(input())):
	c = 0
	k = 0
	n = int(input())
	s = str(input())
	for i in range(n):
		if int(s[i]) % 2 != 0 and (i + 1) % 2 != 0:
			c += 1
		if int(s[i]) % 2 == 0 and (i + 1) % 2 == 0:
			k += 1
	if n % 2 == 0:
		if k > 0:
			print(2)
		else:
			print(1)
	elif c > 0:
		print(1)
	else:
		print(2)


t = int(input())
for testindex in range(t):
	n = input()
	w = input()
	num = 0
	if len(w) % 2:
		if sum(list(map(lambda x: int(x) % 2, list(w[::2])))):
			print(1)
		else:
			print(2)
	elif sum(list(map(lambda x: (int(x) + 1) % 2, list(w[1::2])))):
		print(2)
	else:
		print(1)


def solve(n, d):
	big = float('inf')
	small = float('-inf')
	if n == 1:
		return 1 if d[0] % 2 != 0 else 2
	if n % 2 == 0:
		for i in range(1, n, 2):
			if d[i] % 2 == 0:
				return 2
		return 1
	else:
		for i in range(0, n, 2):
			if d[i] % 2 == 1:
				return 1
		return 2

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		d = input()
		d = [int(i) for i in d]
		ans = solve(n, d)
		print(ans)
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	count = 0
	if len(a) % 2 == 0:
		for k in range(len(a)):
			if (k + 1) % 2 == 0 and int(a[k]) % 2 == 0:
				count = 1
				break
		if count == 1:
			print(2)
		else:
			print(1)
	else:
		for b in range(len(a)):
			if (b + 1) % 2 == 1 and int(a[b]) % 2 == 1:
				count = 1
				break
		if count == 1:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	digits = [int(c) for c in input()]
	ans = None
	if n & 1:
		for i in range(0, n, 2):
			if digits[i] & 1:
				ans = True
				break
		else:
			ans = False
	else:
		for i in range(1, n, 2):
			if digits[i] % 2 == 0:
				ans = False
				break
		else:
			ans = True
	print(1 if ans else 2)


for s in [*open(0)][2::2]:
	a = [ord(x) % 2 for x in s]
	print(1 + (1 not in a[:-1:2], 0 in a[1:-1:2])[len(a) % 2])


t = int(input())
for i in range(t):
	n = int(input())
	(n1, n2) = (0, 0)
	s = input()
	for j in range(n):
		if int(s[j]) % 2 != (j + 1) % 2:
			if j % 2:
				n2 += 1
			else:
				n1 += 1
	if n % 2:
		if n1 <= n // 2:
			print(1)
		else:
			print(2)
	elif n2 <= (n - 1) // 2:
		print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	bCnts = n // 2
	rCnts = n - bCnts
	rOddCnts = 0
	bEvenCnts = 0
	for i in range(n):
		if (i + 1) % 2 == 1 and int(s[i]) % 2 == 1:
			rOddCnts += 1
		if (i + 1) % 2 == 0 and int(s[i]) % 2 == 0:
			bEvenCnts += 1
	if n % 2 == 1:
		if rOddCnts > 0:
			print(1)
		else:
			print(2)
	elif bEvenCnts > 0:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, list(input())))
	if n % 2:
		odd = False
		for i in range(0, n, 2):
			if arr[i] % 2:
				odd = True
				break
		if odd:
			print(1)
		else:
			print(2)
	else:
		even = False
		for i in range(1, n, 2):
			if arr[i] % 2 == 0:
				even = True
				break
		if even:
			print(2)
		else:
			print(1)


from collections import defaultdict, OrderedDict, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from queue import Queue, PriorityQueue
from heapq import heapify, heappop, heappush
from statistics import median
from math import gcd, sqrt, floor, factorial, ceil, log2, log10
import fractions
import copy
from copy import deepcopy
import sys
sys.setrecursionlimit(10 ** 7)
import math
import os
import bisect
import collections
mod = pow(10, 9) + 7
import random
from random import random, randint, randrange

def ncr(n, r, p=mod):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
inf = float('inf')
adj = defaultdict(set)
visited = defaultdict(int)

def addedge(a, b):
	adj[a].add(b)
	adj[b].add(a)

def bfs(v):
	q = Queue()
	q.put(v)
	visited[v] = 1
	while q.qsize() > 0:
		s = q.get_nowait()
		print(s)
		for i in adj[s]:
			if visited[i] == 0:
				q.put(i)
				visited[i] = 1

def dfs(v, visited):
	if visited[v] == 1:
		return
	visited[v] = 1
	print(v)
	for i in adj[v]:
		dfs(i, visited)

def reverse_bisect_right(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x > a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

def reverse_bisect_left(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x >= a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

class MaxHeap:

	def __init__(self, maxsize):
		self.maxsize = maxsize
		self.size = 0
		self.Heap = [0] * (self.maxsize + 1)
		self.Heap[0] = sys.maxsize
		self.FRONT = 1

	def parent(self, pos):
		return pos // 2

	def leftChild(self, pos):
		return 2 * pos

	def rightChild(self, pos):
		return 2 * pos + 1

	def isLeaf(self, pos):
		if pos >= self.size // 2 and pos <= self.size:
			return True
		return False

	def swap(self, fpos, spos):
		(self.Heap[fpos], self.Heap[spos]) = (self.Heap[spos], self.Heap[fpos])

	def maxHeapify(self, pos):
		if not self.isLeaf(pos):
			if self.Heap[pos] < self.Heap[self.leftChild(pos)] or self.Heap[pos] < self.Heap[self.rightChild(pos)]:
				if self.Heap[self.leftChild(pos)] > self.Heap[self.rightChild(pos)]:
					self.swap(pos, self.leftChild(pos))
					self.maxHeapify(self.leftChild(pos))
				else:
					self.swap(pos, self.rightChild(pos))
					self.maxHeapify(self.rightChild(pos))

	def insert(self, element):
		if self.size >= self.maxsize:
			return
		self.size += 1
		self.Heap[self.size] = element
		current = self.size
		while self.Heap[current] > self.Heap[self.parent(current)]:
			self.swap(current, self.parent(current))
			current = self.parent(current)

	def Print(self):
		for i in range(1, self.size // 2 + 1):
			print(' PARENT : ' + str(self.Heap[i]) + ' LEFT CHILD : ' + str(self.Heap[2 * i]) + ' RIGHT CHILD : ' + str(self.Heap[2 * i + 1]))

	def extractMax(self):
		popped = self.Heap[self.FRONT]
		self.Heap[self.FRONT] = self.Heap[self.size]
		self.size -= 1
		self.maxHeapify(self.FRONT)
		return popped

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

def get_str_list_in_int():
	return [int(i) for i in list(input())]

def get_str_list():
	return list(input())

def get_map():
	return map(int, input().split())

def input_int():
	return int(input())

def matrix(a, b):
	return [[0 for i in range(b)] for j in range(a)]

def swap(a, b):
	return (b, a)

def find_gcd(l):
	a = l[0]
	for i in range(len(l)):
		a = gcd(a, l[i])
	return a

def is_prime(n):
	sqrta = int(sqrt(n))
	for i in range(2, sqrta + 1):
		if n % i == 0:
			return 0
	return 1

def prime_factors(n):
	sqrta = int(sqrt(n))
	for i in range(2, sqrta + 1):
		if n % i == 0:
			return [i] + prime_factors(n // i)
	return [n]
nc = 'NO'
yc = 'YES'
ns = 'No'
ys = 'Yes'
t = input_int()
for i in range(t):
	n = int(input())
	l = [int(i) for i in list(input())]
	if n % 2 == 1:
		dict = set(l[::2])
		odd = [1, 3, 5, 7, 9]
		for i in odd:
			if i in dict:
				print(1)
				break
		else:
			print(2)
	else:
		dict = set(l[1::2])
		even = [0, 2, 4, 6, 8]
		for i in even:
			if i in dict:
				print(2)
				break
		else:
			print(1)


for i in ' ' * int(input()):
	n = int(input())
	f = (n + 1) % 2
	s = input()[f::2]
	for s in s:
		if (int(s) + f) % 2:
			print(f + 1)
			break
	else:
		print(1 if f == 1 else 2)


def ans(a, n):
	odd = []
	even = []
	for i in range(1, n + 1):
		if (i - 1) % 2 == 0:
			odd.append(a[i - 1])
		else:
			even.append(a[i - 1])
	if n % 2 == 0:
		for i in even:
			if i % 2 == 0:
				return 2
		return 1
	if n % 2 == 1:
		for i in odd:
			if i % 2 == 1:
				return 1
		return 2
m = int(input())
for i in range(m):
	n = int(input())
	arr = input()
	a = []
	for i in arr:
		a.append(int(i))
	print(ans(a, n))


def main():
	t = int(input())
	while t > 0:
		n = int(input())
		st = list(input())
		rz_od = []
		rz_ev = []
		br_od = []
		br_ev = []
		if n == 1:
			if int(st[0]) % 2 == 0:
				print('2')
			else:
				print('1')
		else:
			for i in range(n):
				if (i + 1) % 2 == 0:
					ele = int(st[i])
					if ele % 2 == 0:
						br_ev.append(ele)
					else:
						br_od.append(ele)
				else:
					ele = int(st[i])
					if ele % 2 == 0:
						rz_ev.append(ele)
					else:
						rz_od.append(ele)
			rz = list(rz_ev + rz_od)
			br = list(br_od + br_ev)
			if len(rz) > len(br):
				if rz[len(br)] % 2 == 0:
					print('2')
				else:
					print('1')
			elif len(br) > len(rz):
				if br[len(rz)] % 2 == 0:
					print('2')
				else:
					print('1')
			elif len(rz) == len(br):
				if br[-1] % 2 == 0:
					print('2')
				else:
					print('1')
		t -= 1
main()


for _ in range(int(input())):
	n = int(input())
	u = list(map(int, list(input())))
	if n % 2 == 0:
		for i in range(1, n, 2):
			if u[i] % 2 == 0:
				print(2)
				break
		else:
			print(1)
	else:
		for i in range(0, n, 2):
			if u[i] % 2 == 1:
				print(1)
				break
		else:
			print(2)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = input()
	oR = 0
	eR = 0
	oB = 0
	eB = 0
	for i in range(n):
		if i % 2 != 0:
			if int(s[i]) % 2 == 0:
				eB += 1
			else:
				oB += 1
		elif int(s[i]) % 2 == 0:
			eR += 1
		else:
			oR += 1
	if (n - 1) % 2 == 0:
		c = (n - 1) // 2
		if c - eR >= 0 and oR > 0:
			print(1)
		else:
			print(2)
	else:
		cR = (n - 1) // 2 + 1
		cB = (n - 1) // 2
		if cB - oB >= 0 and eB > 0:
			print(2)
		else:
			print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	s = [int(i) for i in s]
	(odd, even) = (False, False)
	for i in range(0, n, 2):
		if s[i] % 2 == 1:
			odd = True
		if i + 1 < n and s[i + 1] % 2 == 0:
			even = True
	if n % 2 == 0:
		if even:
			print(2)
		else:
			print(1)
	elif odd:
		print(1)
	else:
		print(2)


for i in range(int(input())):
	length = int(input())
	l = input()
	if length == 1:
		if int(l[0]) % 2 != 0:
			print('1')
		else:
			print('2')
	elif length % 2 == 0:
		flag_even = 0
		for i in range(1, len(l), 2):
			if int(l[i]) % 2 == 0:
				flag_even = 1
				break
		if flag_even == 0:
			print(1)
		else:
			print(2)
	else:
		flag_odd = 0
		for i in range(0, len(l), 2):
			if int(l[i]) % 2 != 0:
				flag_odd = 1
				break
		if flag_odd == 0:
			print(2)
		else:
			print(1)


for i in range(0, int(input())):
	n = int(input())
	a = list(input())
	m = []
	n = []
	for j in range(0, len(a)):
		if j % 2 == 0:
			m.append(a[j])
		else:
			n.append(a[j])
	if len(a) % 2 == 0:
		h = 0
		for k in n:
			if int(k) % 2 == 0:
				print(2)
				h = 1
				break
		if h == 0:
			print(1)
	else:
		h = 0
		for k in m:
			if int(k) % 2 != 0:
				print(1)
				h = 1
				break
		if h == 0:
			print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	r_even = 0
	r_odd = 0
	b_even = 0
	b_odd = 0
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2 == 0:
				r_even += 1
			else:
				r_odd += 1
		elif int(s[i]) % 2 == 0:
			b_even += 1
		else:
			b_odd += 1
	for i in range(1, n):
		if i % 2 != 0:
			if r_even > 0:
				r_even -= 1
			else:
				r_odd -= 1
		elif b_odd > 0:
			b_odd -= 1
		else:
			b_even -= 1
	if r_even == 0 and r_odd != 0:
		print(1)
	elif b_odd != 0 and b_even == 0:
		print(1)
	else:
		print(2)


n_matches = int(input())

def check_parity(values, condition, v, d):
	parity = [value for value in values if value % 2 == condition]
	if len(parity) == len(values):
		return d
	return v
for i in range(n_matches):
	digit_number = int(input())
	digits = input()
	raze = [int(digit) for digit in digits[::2]]
	breach = [int(digit) for digit in digits[1::2]]
	if digit_number % 2 == 1:
		result = check_parity(raze, 0, 1, 2)
	else:
		result = check_parity(breach, 1, 2, 1)
	print(result)


TC = int(input())
for tc in range(TC):
	N = int(input())
	S = input()
	rc0 = 0
	rc1 = 0
	bc0 = 0
	bc1 = 0
	for (i, s) in enumerate(S, 1):
		if i & 1 == 1:
			if int(s) & 1 == 1:
				rc1 += 1
			else:
				rc0 += 1
		elif int(s) & 1 == 1:
			bc1 += 1
		else:
			bc0 += 1
	if N & 1 == 1:
		if rc1 > 0:
			print(1)
		else:
			print(2)
	elif bc0 > 0:
		print(2)
	else:
		print(1)


from math import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from collections import Counter as ctr
from collections import deque as dq
from array import array
from re import search
inp = lambda : int(input())
li = lambda : list(map(int, input().split()))
ls = lambda : list(input())
arr = lambda a: array('i', a)
bi = lambda n: bin(n).replace('0b', '')
yn = lambda f: print('NYOE S'[f::2])
sbstr = lambda a, s: search('.*'.join(a), s)

def pos(a, i):
	while a > i:
		a = a // 2
		if a == i:
			return True
	return False

def solve():
	for _ in range(inp()):
		n = inp()
		s = list(map(int, ls()))
		a = all((x % 2 == 0 for x in s[::2]))
		b = all((x % 2 == 1 for x in s[1::2]))
		print([2 - b, 1 + a][n % 2])
solve()


for _ in range(int(input())):
	n = int(input())
	s = input()
	if n & 1:
		for i in range(0, n, 2):
			if s[i] in '13579':
				s = 1
				print(1)
				break
		else:
			print(2)
	else:
		for i in range(1, n, 2):
			if s[i] in '24680':
				print(2)
				break
		else:
			print(1)


t = int(input())
while t:
	t -= 1
	odd = 0
	even = 0
	N = int(input())
	digits = [int(i) for i in input()]
	if N == 1:
		if int(digits[0]) % 2 == 0:
			print(2)
		else:
			print(1)
	elif N % 2 != 0:
		for i in range(0, len(digits), 2):
			if digits[i] % 2 != 0:
				odd += 1
			else:
				even += 1
		if odd >= 1:
			print(1)
		else:
			print(2)
	else:
		for i in range(1, len(digits), 2):
			if digits[i] % 2 != 0:
				odd += 1
			else:
				even += 1
		if even >= 1:
			print(2)
		else:
			print(1)


for t in range(int(input())):
	n = int(input())
	s = input()
	(raze, breach) = ([], [])
	for i in range(n):
		if i % 2 == 0:
			raze.append(int(s[i]))
		else:
			breach.append(int(s[i]))
	if n % 2 != 0:
		(even, odd) = ([], [])
		for i in raze:
			if i % 2 == 0:
				even.append(i)
			else:
				odd.append(i)
		raze = even + odd
		if raze[-1] % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		(even, odd) = ([], [])
		for i in breach:
			if i % 2 == 0:
				even.append(i)
			else:
				odd.append(i)
		breach = odd + even
		if breach[-1] % 2 == 0:
			print(2)
		else:
			print(1)


cases = int(input())
while cases > 0:
	l = int(input())
	num = input()
	if l == 1:
		if int(num) % 2 == 0:
			print(2)
		else:
			print(1)
	elif l % 2 == 1:
		for d in range(0, len(num), 2):
			if int(num[d]) % 2 == 1:
				print(1)
				break
		else:
			print(2)
	else:
		for d in range(1, len(num), 2):
			if int(num[d]) % 2 == 0:
				print(2)
				break
		else:
			print(1)
	cases -= 1


test = int(input())
for _ in range(test):
	n = int(input())
	a = [int(d) % 2 for d in input()]
	o = sum(a[::2])
	e = len(a[1::2]) - sum(a[1::2])
	print((1 if o else 2) if n % 2 == 1 else 2 if e else 1)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = input()
	epen = opon = open = epon = 0
	turn = 1
	for i in range(n):
		if i + 1 & 1:
			if int(s[i]) & 1:
				opon += 1
			else:
				open += 1
		elif int(s[i]) & 1:
			epon += 1
		else:
			epen += 1
	while turn < n:
		if turn & 1:
			if open == 0:
				opon -= 1
			else:
				open -= 1
		elif epon == 0:
			epen -= 1
		else:
			epon -= 1
		turn += 1
	if epon != 0 or opon != 0:
		print(1)
	else:
		print(2)


import math

def ans(n, num):
	if n % 2 == 0:
		for i in range(1, n, 2):
			if num[i] == 0:
				return 2
		return 1
	else:
		for i in range(0, n, 2):
			if num[i] == 1:
				return 1
		return 2
for _ in range(int(input())):
	n = int(input())
	num = [int(i) % 2 for i in input()]
	print(ans(n, num))


for i in range(int(input())):
	n = int(input())
	N = str(int(input()))
	flag = True
	if n % 2 == 0:
		for j in range(1, n, 2):
			if int(N[j]) % 2 == 0:
				flag = False
				break
	else:
		flag = False
		for j in range(0, n, 2):
			if int(N[j]) % 2 != 0:
				flag = True
	if flag == True:
		print(1)
	else:
		print(2)


test_cases = int(input())
for test_case in range(test_cases):
	n = int(input())
	digit = input()
	c = 0
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(digit[i]) % 2 == 0:
				print(2)
				break
			else:
				c += 1
		if c == n // 2:
			print(1)
	else:
		for i in range(0, n, 2):
			if int(digit[i]) % 2 != 0:
				print(1)
				break
			else:
				c += 1
		if c == n // 2 + 1:
			print(2)


import sys
input = sys.stdin.readline

def print(val):
	sys.stdout.write(str(val) + '\n')

def prog():
	for _ in range(int(input())):
		n = int(input())
		s = input().strip()
		if n % 2 == 1:
			has_odd = 0
			for i in range(0, n, 2):
				if int(s[i]) % 2 == 1:
					has_odd = 1
			print(1 if has_odd else 2)
		else:
			has_even = 0
			for i in range(1, n, 2):
				if int(s[i]) % 2 == 0:
					has_even = 1
			print(2 if has_even else 1)
prog()


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	S = [int(s[i]) for i in range(n)]
	RB = [[0, 0], [0, 0]]
	for j in range(n):
		RB[j % 2][S[j] % 2] += 1
	if n % 2 == 0:
		if RB[1][0] > 0:
			print(2)
		else:
			print(1)
	elif RB[0][1] > 0:
		print(1)
	else:
		print(2)


for t in range(int(input())):
	n = int(input())
	a = int(input())
	s = str(a)
	odd = 0
	even = 0
	if n == 1:
		if a % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		for i in range(n):
			if i % 2 == 1 and int(s[i]) % 2 == 1:
				odd += 1
		if odd == n // 2:
			print(1)
		else:
			print(2)
	else:
		for i in range(n):
			if i % 2 == 0 and int(s[i]) % 2 == 0:
				even += 1
		if even == n // 2 + 1:
			print(2)
		else:
			print(1)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		S = input().strip()
		if N % 2 == 1:
			ans = 2
			for i in range(0, N, 2):
				if int(S[i]) % 2 == 1:
					ans = 1
			print(ans)
		else:
			ans = 1
			for i in range(1, N, 2):
				if int(S[i]) % 2 == 0:
					ans = 2
			print(ans)

def __starting_point():
	main()
__starting_point()


for _ in [0] * int(input()):
	n = int(input())
	s = input()
	if n % 2:
		for c in s[::2]:
			if c in '13579':
				print(1)
				break
		else:
			print(2)
	else:
		for c in s[1::2]:
			if c in '24680':
				print(2)
				break
		else:
			print(1)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input()]
	flag = 1
	if n == 1:
		if a[0] % 2 == 0:
			flag = 0
	else:
		aodd = a[::2]
		aeven = a[1::2]
		if n % 2 == 0:
			for j in aeven:
				if j % 2 == 0:
					flag = 0
					break
		else:
			for j in aodd:
				if j % 2 == 1:
					break
			else:
				flag = 0
	if flag:
		print(1)
	else:
		print(2)


from bisect import bisect_left
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math
import heapq
import re

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		ee = 0
		oo = 0
		eo = 0
		oe = 0
		n = iin()
		s = sin()
		l = list(s)
		if n % 2 == 0:
			win = -1
			for i in range(n):
				if (i + 1) % 2 == 0:
					if int(l[i]) % 2 == 0:
						win = 2
			if win == -1:
				print(1)
			else:
				print(2)
		else:
			win = -1
			for i in range(n):
				if (i + 1) % 2 == 1:
					if int(l[i]) % 2 == 1:
						win = 1
			if win == -1:
				print(2)
			else:
				print(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')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = [0, 0]
	for (i, c) in enumerate(s, start=1):
		if i % 2 == 1 and int(c) % 2 == 1:
			t[0] = 1
		elif i % 2 == 0 and int(c) % 2 == 0:
			t[1] = 1
	if n % 2 == 1:
		print(1 if t[0] == 1 else 2)
	else:
		print(2 if t[1] == 1 else 1)


T = int(input())
for t in range(T):
	n = int(input())
	s = input()
	if n % 2:
		for i in range(0, n, 2):
			if int(s[i]) % 2:
				print(1)
				break
		else:
			print(2)
	else:
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				print(2)
				break
		else:
			print(1)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	digits = [int(c) % 2 for c in list(input())[:-1]]
	if len(digits) % 2 == 1:
		if sum(digits[::2]) > 0:
			print(1)
		else:
			print(2)
	elif sum(digits[1::2]) < len(digits[1::2]):
		print(2)
	else:
		print(1)


import math
import sys
from sys import *
from bisect import insort
import heapq
import collections
from collections import deque, defaultdict
from itertools import permutations, combinations, combinations_with_replacement
import random
import os
mod = 10 ** 9 + 7
MAX = sys.maxsize
MIN = -sys.maxsize - 1

def isPrime(n):
	if n > 1:
		for i in range(2, n):
			if n % i == 0:
				return False
		else:
			return True
	else:
		return False

def isPanagram(s):
	alphabet = 'abcdefghijklmnopqrstuvwxyz'
	for char in alphabet:
		if char not in s.lower():
			return False
	return True

def isEqual(list1):
	if len(list1) < 0:
		res = True
	res = all((ele == list1[0] for ele in list1))
	if res:
		return True
	else:
		return False

def remove_duplicate(list1):
	final_list = []
	for i in list1:
		if i not in final_list:
			final_list.append(i)
	return final_list % mod

def solve():
	n = int(input())
	s = input()
	arr = list(s)
	(re, ro, be, bo) = (0, 0, 0, 0)
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2 == 0:
				re += 1
			else:
				ro += 1
		elif int(s[i]) % 2 == 0:
			be += 1
		else:
			bo += 1
	count = 1
	for i in range(n - 1):
		if count == 1:
			if re > 0:
				re -= 1
			else:
				ro -= 1
			count = 0
		else:
			if bo > 0:
				bo -= 1
			else:
				be -= 1
			count = 1
	if re or be:
		return 2
	else:
		return 1
t = int(stdin.readline())
for i in range(t):
	result = solve()
	stdout.write(str(result) + '\n')


t = int(input())
while t != 0:
	t -= 1
	ans = 0
	ni = int(input())
	n = input()
	if ni == 1:
		if int(n[0]) % 2 == 0:
			ans = 2
		else:
			ans = 1
	elif ni % 2 == 0:
		ans = 1
		for i in range(1, ni, 2):
			if int(n[i]) % 2 == 0:
				ans = 2
				break
	else:
		ans = 2
		for i in range(0, ni, 2):
			if int(n[i]) % 2 != 0:
				ans = 1
				break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	num = input()
	(first, second) = ([], [])
	for (i, item) in enumerate(num):
		if (i + 1) % 2 == 1:
			first.append(int(item))
		else:
			second.append(int(item))
	turn = 1
	while first and second:
		if turn:
			for (i, item) in enumerate(first):
				if item % 2 == 0:
					del first[i]
					break
			else:
				del first[0]
		else:
			for (i, item) in enumerate(second):
				if item % 2 == 1:
					del second[i]
					break
			else:
				del second[0]
		turn = (turn + 1) % 2
	item = first[0] if first else second[0]
	print(2 - item % 2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list([int(x) for x in input()])
	raiz_odds = 0
	raiz_evens = 0
	briz_odds = 0
	briz_evens = 0
	for i in range(n):
		if i % 2 == 0:
			if s[i] % 2:
				raiz_odds += 1
			else:
				raiz_evens += 1
		elif s[i] % 2:
			briz_odds += 1
		else:
			briz_evens += 1
	if n % 2:
		if raiz_odds:
			print(1)
		else:
			print(2)
	elif briz_evens:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = int(input())
	if n == 1:
		if a % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		a = list(str(a))
		a = list(map(int, a))
		if n % 2 != 0:
			c = 0
			for i in range(0, n, 2):
				if a[i] % 2 != 0:
					c += 1
					break
			if c:
				print(1)
			else:
				print(2)
		elif n % 2 == 0:
			c = 0
			for i in range(1, n, 2):
				if a[i] % 2 == 0:
					c += 1
					break
			if c:
				print(2)
			else:
				print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	d = input()
	if n == 1:
		d = int(d)
		print(['2', '1'][d % 2])
		continue
	elif n % 2:
		if any((int(x) % 2 for x in d[::2])):
			print('1')
		else:
			print('2')
	elif any((int(x) % 2 == 0 for x in d[1::2])):
		print('2')
	else:
		print('1')


def even_num_on_even_pos(n, num):
	for i in range(n):
		if (i + 1) % 2 == 0 and int(num[i]) % 2 == 0:
			return True
	return False

def odd_num_on_odd_pos(n, num):
	for i in range(n):
		if (i + 1) % 2 == 1 and int(num[i]) % 2 == 1:
			return True
	return False

def who_win(n, num):
	if n % 2 == 0:
		if even_num_on_even_pos(n, num):
			return 2
		else:
			return 1
	elif odd_num_on_odd_pos(n, num):
		return 1
	else:
		return 2
t = int(input())
for i in range(t):
	n = int(input())
	num = input()
	print(who_win(n, num))


import sys
import random
from fractions import Fraction
from math import *

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def linput():
	return list(input())

def rinput():
	return map(int, tinput())

def fiinput():
	return map(float, tinput())

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

def trinput():
	return tuple(rinput())

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

def NOYES(fl):
	if fl:
		print('NO')
	else:
		print('YES')

def YESNO(fl):
	if fl:
		print('YES')
	else:
		print('NO')

def main():
	n = iinput()
	q = [(int(i) + v) % 2 for (v, i) in enumerate(list(input()))]
	print(1 + n % 2 * (sum(q[0::2]) == 0) + (n + 1) % 2 * (sum(q[1::2]) != 0))
for i in range(iinput()):
	main()


def code1():
	(o1, e2) = (0, 0)
	for i in range(n):
		if i & 1:
			if int(string1[i]) % 2 == 0:
				e2 += 1
		elif int(string1[i]) & 1:
			o1 += 1
	return (o1, e2)

def code2(o1):
	if o1 > 0:
		print(1)
	else:
		print(2)

def code3(e2):
	if e2 > 0:
		print(2)
	else:
		print(1)
for _ in range(int(input())):
	n = int(input())
	string1 = input()
	(odd_count, even_count) = code1()
	if n & 1:
		code2(odd_count)
	else:
		code3(even_count)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = input()
		if n % 2 == 1:
			for i in range(0, n, 2):
				if int(s[i]) % 2 == 1:
					print(1)
					break
			else:
				print(2)
		else:
			for i in range(1, n, 2):
				if int(s[i]) % 2 == 0:
					print(2)
					break
			else:
				print(1)
main()


t = int(input())
for tc in range(t):
	n = int(input())
	s = input()
	ans = 1
	if n % 2 == 0:
		ans = 2
	if ans == 1:
		flag = 0
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 1:
				flag = 1
				break
		if flag == 0:
			ans = 2
	else:
		flag = 0
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				flag = 1
				break
		if flag == 0:
			ans = 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	t = input()
	if n == 1:
		if int(t[0]) % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		winner = 1
		for i in t[1::2]:
			if int(i) % 2 == 0:
				winner = 2
				break
		print(winner)
	else:
		winner = 2
		for i in t[::2]:
			if int(i) % 2 != 0:
				winner = 1
				break
		print(winner)


a = int(input())
for i in range(a):
	b = int(input())
	c = input()
	d = list(map(int, str(c)))
	x1 = 0
	x2 = 0
	for j in range(b):
		if (j + 1) % 2 == 0:
			if d[j] % 2 == 0:
				x1 = 9
				break
	for j in range(b):
		if (j + 1) % 2 != 0:
			if d[j] % 2 != 0:
				x2 = 9
				break
	if b % 2 == 0:
		if x1 == 9:
			print(2)
		else:
			print(1)
	elif x2 == 9:
		print(1)
	else:
		print(2)


def read_int():
	return int(input())
t = read_int()
for case_num in range(t):
	n = read_int()
	s = input()
	a = 0
	b = 0
	for (i, c) in enumerate(s):
		if i % 2 == 0 and int(c) % 2 == 1:
			a += 1
		if i % 2 == 1 and int(c) % 2 == 0:
			b += 1
	if n % 2 == 1:
		print(1 if a > 0 else 2)
	else:
		print(2 if b > 0 else 1)


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	for i in range(len(a)):
		a[i] = int(a[i])
	temp = 0
	if n % 2 == 1:
		temp = 2
		for i in range(n):
			if i % 2 == 0 and a[i] % 2 == 1:
				temp = 1
	else:
		temp = 1
		for i in range(n):
			if i % 2 == 1 and a[i] % 2 == 0:
				temp = 2
	print(temp)


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	s = stdin.readline().strip('\n')
	a = [int(i) for i in s]
	(cne, cno) = (0, 0)
	for i in range(0, n):
		if (i + 1) % 2 == 1:
			if a[i] % 2 == 1:
				cno += 1
		elif a[i] % 2 == 0:
			cne += 1
	chk = False
	if n % 2 == 1:
		if cno >= 1:
			chk = True
	elif cne == 0:
		chk = True
	if chk:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	n = int(input())
	game = list(map(int, input()))
	if n % 2 == 0:
		winner = 1
		for j in range(1, n, 2):
			if game[j] % 2 == 0:
				winner = 2
				break
		print(winner)
	else:
		winner = 2
		for j in range(0, n, 2):
			if game[j] % 2 == 1:
				winner = 1
				break
		print(winner)


t = int(input())
while t:
	t -= 1
	n = int(input())
	digit = input()
	win = False
	if len(digit) % 2 == 1:
		for i in range(0, len(digit), 2):
			if int(digit[i]) % 2 == 1:
				win = True
				break
		if win:
			print('1')
		else:
			print('2')
	else:
		for i in range(1, len(digit), 2):
			if int(digit[i]) % 2 == 0:
				win = True
				break
		if win:
			print('2')
		else:
			print('1')


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input()))
	l = len(x)
	x.insert(0, 0)
	if l % 2 == 0:
		for i in range(1, l + 1):
			if i % 2 == 0:
				if x[i] % 2 == 0:
					print(2)
					break
		else:
			print(1)
	else:
		for i in range(1, l + 1):
			if i % 2 != 0:
				if x[i] % 2 != 0:
					print(1)
					break
		else:
			print(2)


T = int(input())
for t in range(T):
	n = int(input())
	b = input()
	odds = []
	evens = []
	for i in range(len(b)):
		if i % 2 == 1:
			evens.append(int(b[i]))
		else:
			odds.append(int(b[i]))
	if len(odds) == len(evens):
		if any((x % 2 == 0 for x in evens)):
			print(2)
		else:
			print(1)
	elif any((x % 2 == 1 for x in odds)):
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	flag = False
	if n % 2:
		for i in range(len(s)):
			if i % 2 == 0:
				if int(s[i]) % 2:
					flag = True
					break
		if flag:
			print('1')
		else:
			print('2')
	else:
		for i in range(len(s)):
			if i % 2:
				if int(s[i]) % 2 == 0:
					flag = True
					break
		if flag:
			print('2')
		else:
			print('1')


for _ in range(int(input())):
	n = int(input())
	s = int(input())
	st = list(str(s))
	if n == 1:
		if s % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 > 0:
		flag = 0
		for i in range(len(st)):
			if i % 2 == 0 and int(st[i]) % 2 != 0:
				flag = 1
				break
		if flag == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		flag = 0
		for i in range(len(st)):
			if i % 2 != 0 and int(st[i]) % 2 == 0:
				flag = 1
				break
		if flag == 0:
			print(1)
		else:
			print(2)


N = int(input())
for _ in range(N):
	l = int(input())
	(ro, re, bo, be) = (0, 0, 0, 0)
	for (idx, c) in enumerate(input(), 1):
		c = int(c)
		if idx & 1:
			if c & 1:
				ro += 1
			else:
				re += 1
		elif c & 1:
			bo += 1
		else:
			be += 1
	flag = 0
	while ro + re + bo + be > 1:
		if not flag:
			if re:
				re -= 1
			else:
				ro -= 1
		elif bo:
			bo -= 1
		else:
			be -= 1
		flag ^= 1
	if ro + bo >= 1:
		print(1)
	else:
		print(2)


from __future__ import print_function
import sys
input = sys.stdin.readline
sys.setrecursionlimit(400000)

def solve(n, S):
	Raze_has_odd = False
	Breach_has_even = False
	for i in range(n):
		if (i + 1) % 2 == 1:
			if S[i] % 2 == 1:
				Raze_has_odd = True
		elif S[i] % 2 == 0:
			Breach_has_even = True
	if n % 2 == 1:
		if Raze_has_odd:
			print(1)
		else:
			print(2)
	elif Breach_has_even:
		print(2)
	else:
		print(1)

def main():
	t = int(input().strip())
	for _ in range(t):
		n = int(input().strip())
		S = input().strip()
		S = list(map(int, S))
		solve(n, S)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	r = input()
	r = [int(x) for x in r]
	f = 0
	s = 0
	for i in range(n):
		if i & 1 == 0 and r[i] & 1 == 1:
			f = 1
		if i & 1 and r[i] & 1 == 0:
			s = 1
	if n & 1:
		if f:
			print(1)
		else:
			print(2)
	elif s:
		print(2)
	else:
		print(1)


q = int(input())
for _ in range(q):
	n = int(input())
	s = input()
	s = list(map(int, s))
	r = []
	prz = []
	for i in range(n):
		if i % 2 == 0:
			r.append(s[i] % 2)
		else:
			prz.append(s[i] % 2)
	if n % 2 == 0:
		if prz.count(0) > 0:
			print(2)
		else:
			print(1)
	elif r.count(1) > 0:
		print(1)
	else:
		print(2)


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
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 RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(inverse(farr[-1], mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class smt:

	def __init__(self, l, r, arr):
		self.l = l
		self.r = r
		self.value = (1 << 31) - 1 if l < r else arr[l]
		mid = (l + r) // 2
		if l < r:
			self.left = smt(l, mid, arr)
			self.right = smt(mid + 1, r, arr)
			self.value &= self.left.value & self.right.value

	def setvalue(self, x, val):
		if self.l == self.r:
			self.value = val
			return
		mid = (self.l + self.r) // 2
		if x <= mid:
			self.left.setvalue(x, val)
		else:
			self.right.setvalue(x, val)
		self.value = self.left.value & self.right.value

	def ask(self, l, r):
		if l <= self.l and r >= self.r:
			return self.value
		val = (1 << 31) - 1
		mid = (self.l + self.r) // 2
		if l <= mid:
			val &= self.left.ask(l, r)
		if r > mid:
			val &= self.right.ask(l, r)
		return val

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d
t = N()
for i in range(t):
	n = N()
	x = input()
	if n & 1:
		ans = 1 if any((int(x[i]) & 1 for i in range(0, n, 2))) else 2
	else:
		ans = 2 if any((not int(x[i]) & 1 for i in range(1, n, 2))) else 1
	print(ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var, end='\n'):
	sys.stdout.write(str(var) + end)

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	s = list(map(int, data()))
	odd = 2
	if n & 1:
		for i in range(0, n, 2):
			if s[i] & 1:
				odd = 1
				break
		out(odd)
		continue
	even = 1
	for i in range(1, n, 2):
		if not s[i] & 1:
			even = 2
			break
	out(even)


for u in range(int(input())):
	n = int(input())
	s = input()
	l = list(map(int, s))
	(x, y) = (0, 0)
	for i in range(n):
		if i % 2 == 0:
			if l[i] % 2 == 1:
				x = 1
		elif l[i] % 2 == 0:
			y = 1
	if n % 2 == 1:
		if x == 1:
			print(1)
		else:
			print(2)
	elif y == 1:
		print(2)
	else:
		print(1)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	digit = input()
	if n == 1:
		if int(digit) % 2 == 0:
			print('2')
		else:
			print('1')
	elif n % 2 == 0:
		flag = False
		for x in range(1, n, 2):
			if int(digit[x]) % 2 == 0:
				flag = not flag
				print('2')
				break
		if not flag:
			print('1')
	else:
		flag = False
		for x in range(0, n, 2):
			if int(digit[x]) % 2 != 0:
				flag = not flag
				print('1')
				break
		if not flag:
			print('2')


for _ in range(int(input())):
	n = int(input())
	s = input()
	even = 0
	odd = 0
	even_2 = 0
	odd_2 = 0
	for i in range(n):
		if i % 2 == 0:
			odd += 1
			if int(s[i]) % 2 == 1:
				odd_2 += 1
		else:
			even += 1
			if int(s[i]) % 2 == 0:
				even_2 += 1
	if odd == even:
		if even_2 > 0:
			print('2')
		else:
			print('1')
	elif odd > even:
		if odd_2 > 0:
			print('1')
		else:
			print('2')


for x in range(int(input())):
	k = int(input())
	n = input()
	t = 1
	a = []
	b = []
	c = 0
	for i in n:
		if t % 2 and int(i) % 2:
			a.append(i)
		elif t % 2 == 0 and int(i) % 2 == 0:
			b.append(i)
		if int(i) % 2:
			c += 1
		t += 1
	if k % 2 == 0:
		if len(b) > 0:
			print(2)
		else:
			print(1)
	elif len(a) > 0:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	n = int(input())
	num = input()
	raze_odd = 0
	raze_even = 0
	breach_even = 0
	breach_odd = 0
	for j in range(1, n + 1):
		x = int(num[j - 1])
		if j % 2 == 1:
			if x % 2 == 0:
				raze_even += 1
			else:
				raze_odd += 1
		elif x % 2 == 0:
			breach_even += 1
		else:
			breach_odd += 1
	if n % 2 == 0:
		if breach_even > 0:
			print('2')
		else:
			print('1')
	elif raze_odd > 0:
		print('1')
	else:
		print('2')


t = int(input())
for i in range(t):
	n = int(input())
	d = input()
	if n == 1:
		if int(d) % 2 != 0:
			print(1)
		else:
			print(2)
	elif n % 2 != 0:
		oddForRaze = False
		for i in range(0, n, 2):
			if int(d[i]) % 2 != 0:
				print(1)
				oddForRaze = True
				break
		if not oddForRaze:
			print(2)
	else:
		evenForBreach = False
		for i in range(1, n, 2):
			if int(d[i]) % 2 == 0:
				print(2)
				evenForBreach = True
				break
		if not evenForBreach:
			print(1)


test = int(input())
for t in range(0, test):
	n = int(input())
	a = input()
	be = 0
	bo = 0
	re = 0
	ro = 0
	for i in range(0, n):
		if (i + 1) % 2:
			if int(a[i]) % 2:
				ro += 1
			else:
				re += 1
		elif int(a[i]) % 2:
			bo += 1
		else:
			be += 1
	if n % 2:
		if ro > 0:
			print(1)
		else:
			print(2)
	elif be > 0:
		print(2)
	else:
		print(1)


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	n = int(input())
	a = list(map(int, input()))
	if n % 2 == 0:
		f = 0
		for i in range(n):
			if (i + 1) % 2 == 0 and a[i] % 2 == 0:
				f = 1
				break
		if f == 1:
			print(2)
		else:
			print(1)
	else:
		f = 0
		for i in range(n):
			if (i + 1) % 2 != 0 and a[i] % 2 != 0:
				f = 1
				break
		if f == 1:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	num = input()
	num = list(num)
	for i in range(len(num)):
		num[i] = int(num[i])
	if n == 1:
		if num[0] % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		f = 0
		for i in range(1, n, 2):
			if num[i] % 2 == 0:
				f = 1
				break
		if f == 1:
			print(2)
		else:
			print(1)
	else:
		f = 0
		for i in range(0, n, 2):
			if num[i] % 2 == 1:
				f = 1
				break
		if f == 1:
			print(1)
		else:
			print(2)


def get(slice, v):
	for i in s[slice]:
		if int(i) % 2 == v:
			return True
	return False
for _ in range(int(input())):
	n = int(input())
	s = input()
	if len(s) % 2:
		if get(slice(0, len(s), 2), 1):
			print(1)
		else:
			print(2)
	elif get(slice(1, len(s), 2), 0):
		print(2)
	else:
		print(1)


def hasmodulo(s, a):
	for i in s:
		if int(i) % 2 == a:
			return True
	return False
for _ in range(int(input())):
	n = int(input())
	s = input()
	if n % 2 == 0:
		if hasmodulo(s[1::2], 0):
			print(2)
		else:
			print(1)
	elif hasmodulo(s[0::2], 1):
		print(1)
	else:
		print(2)


import sys
import os
from io import BytesIO, IOBase
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')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, num):
	besta = False
	bestb = False
	for i in range(1, n + 1):
		if int(num[i - 1]) % 2 and i % 2:
			besta = True
		elif int(num[i - 1]) % 2 == 0 and i % 2 == 0:
			bestb = True
	if n % 2:
		if besta == bestb == True:
			return 1
		elif besta == True:
			return 1
		elif bestb == True:
			return 2
		else:
			return 2
	elif besta == bestb == True:
		return 2
	elif besta == True:
		return 1
	elif bestb == True:
		return 2
	else:
		return 1
for _ in range(int(input())):
	n = int(input())
	num = input()
	print(solve(n, num))


a = int(input())
for j in range(a):
	b = int(input())
	c = input()
	t = 0
	if b % 2:
		for i in range(0, b, 2):
			if int(c[i]) % 2 == 0:
				t += 1
		if (b + 1) // 2 == t:
			print('2')
		else:
			print('1')
	else:
		for ii in range(1, b, 2):
			if int(c[ii]) % 2 == 1:
				t += 1
		if b // 2 == t:
			print('1')
		else:
			print('2')


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	if n == 1:
		if int(a) % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		c = 0
		for i in range(1, n, 2):
			if int(a[i]) % 2 != 0:
				c += 1
		if c == n // 2:
			print(1)
		else:
			print(2)
	else:
		c = 0
		for i in range(0, n, 2):
			if int(a[i]) % 2 == 0:
				c += 1
		if c == n // 2 + 1:
			print(2)
		else:
			print(1)


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(i) for i in input()]
	if n == 1:
		if arr[0] % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		odd = 0
		even = 0
		for i in range(len(arr)):
			if (i + 1) % 2 != 0 and arr[i] % 2 != 0:
				odd += 1
			if (i + 1) % 2 == 0 and arr[i] % 2 == 0:
				even += 1
		if n % 2 != 0:
			if odd != 0:
				print(1)
			else:
				print(2)
		elif even != 0:
			print(2)
		else:
			print(1)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = input()
	if n % 2 == 0:
		flag = 0
		for i in range(1, n, 2):
			if int(a[i]) % 2 == 0:
				flag += 1
				break
		if flag:
			print(2)
		else:
			print(1)
	else:
		flag = 0
		for i in range(0, n, 2):
			if int(a[i]) % 2 == 1:
				flag += 1
				break
		if flag:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	user_input = [int(digit) for digit in input()]
	raze = []
	breach = []
	for i in range(n):
		if i % 2 == 0:
			if user_input[i] % 2 == 0:
				raze.insert(0, user_input[i])
			else:
				raze.append(user_input[i])
		elif user_input[i] % 2:
			breach.insert(0, user_input[i])
		else:
			breach.append(user_input[i])
	if len(raze) - len(breach):
		if raze[-1] % 2 == 0:
			print(2)
		else:
			print(1)
	elif breach[-1] % 2 == 0:
		print(2)
	else:
		print(1)


test = int(input())
for _ in range(test):
	n = int(input())
	s = input()
	flag = 0
	if len(s) % 2 == 1:
		for i in range(0, len(s), 2):
			if int(s[i]) % 2 == 1:
				flag = 1
				break
		if flag:
			print('1')
		else:
			print('2')
	else:
		for i in range(1, len(s), 2):
			if int(s[i]) % 2 == 0:
				flag = 1
				break
		if flag:
			print('2')
		else:
			print('1')


n = int(input())
for i in range(n):
	ln = int(input())
	num = list(input())
	(re, ro, bo, be) = (0, 0, 0, 0)
	for h in range(ln):
		if h % 2 == 0:
			if int(num[h]) % 2 == 0:
				re += 1
			else:
				ro += 1
		elif int(num[h]) % 2 == 0:
			be += 1
		else:
			bo += 1
	if ln % 2 == 0:
		if be != 0:
			print('2')
		else:
			print('1')
	elif ro != 0:
		print('1')
	else:
		print('2')


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	x = 0
	y = 0
	for j in range(1, n + 1):
		if j % 2 == 1:
			if int(a[j - 1]) % 2 != 0:
				x += 1
		elif int(a[j - 1]) % 2 == 0:
			y += 1
	if n % 2 == 0:
		if y > 0:
			print(2)
		else:
			print(1)
	elif x > 0:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	S = input().strip()
	R = []
	B = []
	for i in range(n):
		s = int(S[i])
		if i % 2 == 0:
			R.append(s % 2)
		else:
			B.append(s % 2)
	if n % 2 == 0:
		if min(B) == 0:
			print(2)
		else:
			print(1)
	elif max(R) == 1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	(odd, even) = (False, False)
	n = int(input())
	number = input()
	for i in range(1, n + 1):
		if i % 2 == 1:
			odd = odd or int(number[i - 1]) % 2 == 1
		else:
			even = even or int(number[i - 1]) % 2 == 0
	if n % 2 == 1:
		if odd:
			print(1)
		else:
			print(2)
	elif even:
		print(2)
	else:
		print(1)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

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))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def solve():
	n = int(inp())
	s = inp()
	ev = []
	od = []
	iso = 0
	ise = 0
	for i in range(n):
		if i % 2 == 0:
			od.append(int(s[i]))
			if int(s[i]) % 2 == 1:
				iso = 1
		else:
			ev.append(int(s[i]))
			if int(s[i]) % 2 == 0:
				ise = 1
	if n % 2 == 1:
		if iso:
			print('1')
		else:
			print(2)
	elif ise:
		print('2')
	else:
		print('1')
testcase(int(inp()))


def main():
	t = int(input())
	for _ in range(1, t + 1):
		n = int(input())
		x = input()
		turns = n - 1
		num = [int(j) for j in x]
		x = int(x)
		winner = -1
		if turns == 0:
			if x % 2 == 0:
				winner = 2
			else:
				winner = 1
			print(winner)
			continue
		if n % 2 == 0:
			winner = 1
			for i in range(1, n, 2):
				if num[i] % 2 == 0:
					winner = 2
					break
		else:
			winner = 2
			for i in range(0, n, 2):
				if num[i] % 2 != 0:
					winner = 1
					break
		print(winner)
main()


n = int(input())
for i in range(0, n):
	a = int(input())
	b = input()
	h = []
	e = []
	i = 0
	y = 0
	while i < len(b):
		h.append(b[i])
		i = i + 1
		if i < len(b):
			e.append(b[i])
			i = i + 1
	while len(h) != 0 and len(e) != 0:
		y = 0
		for i in range(0, len(h)):
			if int(h[i]) % 2 == 0:
				del h[i]
				y = 1
				break
		if y == 0:
			del h[0]
		y = 0
		for i in range(0, len(e)):
			if int(e[i]) % 2 != 0 and len(h) != 0:
				del e[i]
				y = 1
				break
		if y == 0 and len(h) != 0:
			del e[0]
	if len(e) == 0:
		if int(h[0]) % 2 == 0:
			print('2')
		else:
			print('1')
	elif int(e[0]) % 2 == 0:
		print('2')
	else:
		print('1')


def countfun(l):
	u = 0
	v = 0
	for i in range(len(l)):
		if i % 2 == 1 and l[i] % 2 == 0:
			u += 1
		if i % 2 == 0 and l[i] % 2 == 1:
			v += 1
	return [u, v]
T = int(input())
for t in range(T):
	n = int(input())
	dig = input()
	diglt = list(map(int, list(dig)))
	if n == 1:
		dig = int(dig)
		if dig % 2 == 1:
			print('1')
		if dig % 2 == 0:
			print('2')
	else:
		if n % 2 == 0 and countfun(diglt)[0] > 0:
			print('2')
		if n % 2 == 1 and countfun(diglt)[1] > 0:
			print('1')
		if n % 2 == 0 and countfun(diglt)[0] == 0:
			print('1')
		if n % 2 == 1 and countfun(diglt)[1] == 0:
			print('2')


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

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

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for _ in range(Int()):
		n = Int()
		a = Lstr()
		ce = 0
		c = 0
		for i in range(len(a)):
			if (i + 1) % 2 == 0 and int(a[i]) % 2 == 1:
				ce += 1
			elif (i + 1) % 2 == 1 and int(a[i]) % 2 == 0:
				c += 1
		if n % 2 == 0:
			if ce == n // 2:
				w = 1
			else:
				w = 2
		elif c == (n - 1) // 2 + 1:
			w = 2
		else:
			w = 1
		print(w)
solution()


import math
from collections import deque
from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = input()
	if n == 1:
		if int(s[0]) % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 != 0:
		poss = False
		for i in range(0, n, 2):
			if int(s[i]) % 2 != 0:
				poss = True
				break
		if poss:
			print(1)
		else:
			print(2)
	else:
		poss = False
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				poss = True
				break
		if not poss:
			print(1)
		else:
			print(2)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input()]
	if n == 1:
		print(1 if a[-1] % 2 == 1 else 2)
	elif n % 2 == 0:
		k = 0
		for i in range(n):
			if i % 2 == 1 and a[i] % 2 == 0:
				k += 1
				break
		print(2 if k == 1 else 1)
	elif n % 2 == 1:
		k = 0
		for i in range(n):
			if i % 2 == 0 and a[i] % 2 == 1:
				k += 1
				break
		print(1 if k == 1 else 2)


t = int(input())
while t > 0:
	n = int(input())
	number = input()
	number_ls = [int(i) for i in number]
	(start, last) = (0, n - 1)
	for i in range(n):
		if start >= last:
			break
		if i % 2 == 0:
			if start % 2 == 0:
				if last % 2 == 0:
					if number_ls[last] % 2 == 0:
						last -= 1
					else:
						start += 1
				else:
					start += 1
			else:
				last -= 1
		elif start % 2 != 0:
			if last % 2 != 0:
				if number_ls[last] % 2 != 0:
					last -= 1
				else:
					start += 1
			else:
				start += 1
		else:
			last -= 1
	if number_ls[start] % 2 == 0:
		print(2)
	else:
		print(1)
	t -= 1


def digits(a):
	if a == 0:
		return 0
	return digits(a // 10) + 1
t = int(input())
while t:
	n = int(input())
	num = int(input())
	arr = []
	length = digits(num)
	tmp = num
	while num:
		arr.append(num % 10)
		num = num // 10
	arr.reverse()
	flag = False
	if length == 0 or length == 1:
		flag = tmp % 2
	elif length % 2:
		flag = False
		for i in range(0, length, 2):
			if arr[i] % 2:
				flag = True
	else:
		flag = True
		for i in range(1, length, 2):
			if arr[i] % 2 == 0:
				flag = False
	if flag:
		print(1)
	else:
		print(2)
	t -= 1


t = int(input())
for j in range(t):
	n = int(input())
	no = str(input())
	odd = 0
	even = 0
	if n % 2 == 1:
		for i in range(0, n, 2):
			if int(no[i]) % 2 == 1:
				odd = 1
		if odd == 1:
			print(1)
		else:
			print(2)
	else:
		for i in range(1, n, 2):
			if int(no[i]) % 2 == 0:
				even = 1
		if even == 1:
			print(2)
		else:
			print(1)


result = []
for x in range(int(input())):
	a = int(input())
	b = input()
	l = []
	i = 0
	for y in b:
		c = int(y)
		l.append(c)
	raze = [l[i] for i in range(len(l)) if i % 2 == 0]
	brea = [l[i] for i in range(len(l)) if i % 2 != 0]
	if a % 2 == 0:
		for x in brea:
			if x % 2 == 0:
				n = 2
				result.append(n)
				break
			i += 1
		if i == len(brea):
			n = 1
			result.append(n)
	else:
		for x in raze:
			if x % 2 != 0:
				n = 1
				result.append(n)
				break
			i += 1
		if i == len(raze):
			n = 2
			result.append(n)
for u in result:
	print(u)


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

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

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('0') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	s = inputstringnum()
	if n % 2 == 1:
		ans = 2
		for i in range(n):
			if i % 2 == 0 and s[i] % 2 == 1:
				ans = 1
		print(ans)
	else:
		ans = 1
		for i in range(n):
			if i % 2 == 1 and s[i] % 2 == 0:
				ans = 2
		print(ans)


n = int(input())
for i in range(n):
	r = int(input())
	t = input()
	a = True
	if r % 2 == 0:
		a = False
		for j in range(r // 2):
			if int(t[2 * j + 1]) % 2 == 0:
				a = True
	else:
		a = True
		for j in range((r + 1) // 2):
			if int(t[2 * j]) % 2 == 1:
				a = False
	if a == True:
		print(2)
	else:
		print(1)


def solve(n, s):
	if n % 2:
		s = s[::2]
		for d in s:
			if int(d) % 2:
				return 1
		return 2
	s = s[1::2]
	for d in s:
		if int(d) % 2 == 0:
			return 2
	return 1
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	print(solve(n, s))


for _ in range(int(input())):
	n = int(input())
	number = input()
	raze = [0, 0]
	breach = [0, 0]
	for (ind, digit) in enumerate(number, 1):
		digit = int(digit)
		if ind % 2 == 1:
			if digit % 2 == 0:
				raze[0] += 1
			else:
				raze[1] += 1
		elif digit % 2 == 0:
			breach[0] += 1
		else:
			breach[1] += 1
	if n % 2:
		if raze[1] >= 1:
			print(1)
		else:
			print(2)
	elif breach[0] >= 1:
		print(2)
	else:
		print(1)


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().strip()))
	ev1 = 0
	od1 = 0
	ev2 = 0
	od2 = 0
	for i in range(0, n, 2):
		if l[i] % 2 == 0:
			ev1 += 1
		else:
			od1 += 1
	for i in range(1, n, 2):
		if l[i] % 2 == 0:
			ev2 += 1
		else:
			od2 += 1
	if n % 2 == 0:
		if ev2:
			print(2)
		else:
			print(1)
	elif od1:
		print(1)
	else:
		print(2)
	t -= 1


for _ in range(int(input())):
	q = int(input())
	n = int(input())
	odd_odd = 0
	odd_even = 0
	even_odd = 0
	even_even = 0
	idx = 1
	for i in str(n):
		if idx % 2 == 1:
			if int(i) % 2 == 1:
				odd_odd += 1
			else:
				odd_even += 1
		elif int(i) % 2 == 1:
			even_odd += 1
		else:
			even_even += 1
		idx += 1
	if q % 2 == 0:
		if even_even >= 1:
			print(2)
		else:
			print(1)
	elif odd_odd >= 1:
		print(1)
	else:
		print(2)


import math
from decimal import *
inputed = []
count = int(input())
linesPer = 2
for i in range(count * linesPer):
	inputed.append(input())
t = 0
for i in range(count):
	inputed[t + 1] = list(str(inputed[t + 1]))
	inputed[t + 1] = [int(x) for x in inputed[t + 1]]
	digits = inputed[t + 1]
	n = int(inputed[t])
	razeOdd = 0
	razeEven = 0
	breachOdd = 0
	breachEven = 0
	for i in range(len(digits)):
		index = i + 1
		if index % 2 == 1:
			if digits[i] % 2 == 1:
				razeOdd = 1
			else:
				razeEven = 1
		elif digits[i] % 2 == 1:
			breachOdd = 1
		else:
			breachEven = 1
	if n % 2 == 0:
		if breachEven > 0:
			print(2)
		else:
			print(1)
	elif razeOdd > 0:
		print(1)
	else:
		print(2)
	t += linesPer


for _ in range(int(input())):
	N = int(input())
	string = input()
	(red, blue) = ([], [])
	for i in range(1, N + 1):
		if i % 2 == 0:
			red.append(string[i - 1])
		else:
			blue.append(string[i - 1])
	if N % 2 == 0:
		for i in red:
			if int(i) % 2 == 0:
				print(2)
				break
		else:
			print(1)
	else:
		for i in blue:
			if int(i) % 2 == 1:
				print(1)
				break
		else:
			print(2)


matches = int(input())
userInput = []
for _ in range(matches):
	eachMatch = []
	eachMatch.append(input())
	eachMatch.append(input())
	userInput.append(eachMatch)
for match in userInput:
	string = match[1]
	N = int(match[0])
	aliceOdd = 0
	aliceEven = 0
	bobOdd = 0
	bobEven = 0
	for i in range(len(string)):
		if i % 2 == 0:
			if int(string[i]) % 2 == 0:
				aliceEven += 1
			else:
				aliceOdd += 1
		elif int(string[i]) % 2 == 0:
			bobEven += 1
		else:
			bobOdd += 1
	turn = 1
	while N > 1:
		if turn == 1:
			if aliceEven != 0:
				aliceEven -= 1
			else:
				aliceOdd -= 1
			turn = 0
		else:
			if bobOdd != 0:
				bobOdd -= 1
			else:
				bobEven -= 1
			turn = 1
		N -= 1
	if aliceEven or bobEven:
		print(2)
	else:
		print(1)


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	n = inin()
	a = stin()
	flag = 0
	if n % 2 == 0:
		flag = 1
		for j in range(n):
			if int(a[j]) % 2 == 0 and j % 2 == 1:
				flag = 2
	else:
		flag = 2
		for j in range(n):
			if int(a[j]) % 2 != 0 and j % 2 == 0:
				flag = 1
	print(flag)


even = '13579'
odd = '02468'

def iseven(s):
	for i in range(1, len(s), 2):
		if s[i] in odd:
			return True
	return False

def isodd(s):
	for i in range(0, len(s), 2):
		if s[i] in even:
			return True
	return False
t = int(input())
for _ in range(t):
	n = int(input())
	tab = input()
	if n % 2 == 0:
		x = iseven(tab)
		if x:
			print('2')
		else:
			print('1')
	else:
		x = isodd(tab)
		if x:
			print('1')
		else:
			print('2')


t = int(input())
for you in range(t):
	n = int(input())
	s = input()
	if n % 2 == 0:
		poss = 0
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				poss = 1
				break
		if poss:
			print(2)
		else:
			print(1)
	else:
		poss = 0
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 1:
				poss = 1
				break
		if poss:
			print(1)
		else:
			print(2)


for i in range(int(input())):
	n = int(input())
	a = int(input())
	s = list(map(int, str(a)))
	flag = 0
	d = 0
	for i in range(n):
		if (i + 1) % 2 != 0:
			if s[i] % 2 != 0:
				flag = 1
		elif s[i] % 2 == 0:
			d = 1
	if n == 1:
		if a % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		if d == 1:
			print(2)
		else:
			print(1)
	elif flag == 1:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	if n == 1:
		if int(x) % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	if n == 2:
		if int(x[1]) % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	if n % 2 != 0:
		ans = 2
		for i in range(0, n, 2):
			if int(x[i]) % 2 != 0:
				ans = 1
				break
		print(ans)
	else:
		ans = 1
		for i in range(1, n, 2):
			if int(x[i]) % 2 == 0:
				ans = 2
				break
		print(ans)


for i in range(int(input())):
	n = int(input())
	s = input()
	odds = []
	evens = []
	evenineven = False
	oddinodds = False
	for (i, val) in enumerate(s):
		if i % 2 == 0:
			if int(val) % 2 == 1:
				oddinodds = True
			odds.append(int(val))
		else:
			if int(val) % 2 == 0:
				evenineven = True
			evens.append(int(val))
	if n == 1:
		if odds[0] % 2 == 0:
			print('2')
		else:
			print('1')
	elif n % 2 == 0:
		if evenineven:
			print('2')
		else:
			print('1')
	elif oddinodds:
		print('1')
	else:
		print('2')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	ali = []
	for i in s:
		ali.append(int(i))
	f = 0
	if n % 2 == 0:
		for i in range(1, n, 2):
			if ali[i] % 2 == 0:
				f = 1
		if f == 1:
			print(2)
		else:
			print(1)
	else:
		for i in range(0, n, 2):
			if ali[i] % 2 != 0:
				f = 1
		if f == 1:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	m = input()
	f = 0
	if n & 1:
		for i in range(0, n, 2):
			if int(m[i]) % 2:
				f = 1
				break
		if f:
			print(1)
		else:
			print(2)
	else:
		for i in range(1, n, 2):
			if int(m[i]) % 2 == 0:
				f = 1
				break
		if f:
			print(2)
		else:
			print(1)


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input()))
	if len(a) == 1:
		if a[0] % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		(r, b) = (0, 0)
		for i in range(n):
			if (i + 1) % 2 == 0 and a[i] % 2 == 0:
				b += 1
			elif (i + 1) % 2 == 1 and a[i] % 2 == 1:
				r += 1
		if n % 2 == 0:
			if b > 0:
				print(2)
			else:
				print(1)
		elif r > 0:
			print(1)
		else:
			print(2)


def iinput():
	return [int(i) for i in input().split()]
t = int(input())
for _ in range(t):
	n = int(input())
	mas = [int(i) for i in input()]
	ans = 0
	if n % 2:
		for i in range(0, n, 2):
			if mas[i] % 2:
				ans = 1
		if not ans:
			ans = 2
	else:
		for i in range(1, n, 2):
			if not mas[i] % 2:
				ans = 2
		if not ans:
			ans = 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	k = [int(j) for j in input()]
	flag_raze = 0
	flag_breach = 0
	for i in range(n):
		if i % 2 == 0 and k[i] % 2 != 0:
			flag_raze = 1
		elif i % 2 != 0 and k[i] % 2 == 0:
			flag_breach = 1
	if n % 2 == 0:
		if flag_breach == 1:
			print(2)
		else:
			print(1)
	elif flag_raze == 1:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(0, t):
	n = int(input())
	s = input()
	f1 = 0
	f2 = 0
	if n % 2 == 1:
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 1:
				f1 = 1
				break
		if f1 == 1:
			print(1)
		else:
			print(2)
	else:
		for i in range(0, n, 2):
			if i + 1 < n and int(s[i + 1]) % 2 == 0:
				f2 = 1
				break
		if f2 == 1:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	d = [int(i) for i in input()]
	if n % 2 == 1:
		if 1 in [d[i] % 2 for i in range(0, n, 2)]:
			print(1)
		else:
			print(2)
	elif 0 in [d[i] % 2 for i in range(1, n, 2)]:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	q = int(input())
	n = int(input())
	odd_odd = 0
	odd_even = 0
	even_odd = 0
	even_even = 0
	idx = 1
	for i in str(n):
		if idx % 2 == 1:
			if int(i) % 2 == 1:
				odd_odd += 1
			else:
				odd_even += 1
		elif int(i) % 2 == 1:
			even_odd += 1
		else:
			even_even += 1
		idx += 1
	left = q
	chance = 'raze'
	while left > 1:
		if chance == 'raze':
			if odd_even:
				odd_even -= 1
			else:
				odd_odd -= 1
			chance = 'breach'
		else:
			if even_odd:
				even_odd -= 1
			else:
				even_even -= 1
			chance = 'raze'
		left -= 1
	if odd_odd or even_odd:
		print(1)
	else:
		print(2)


T = int(input())
for i in range(T):
	n = int(input())
	string = input()
	count = 0
	if n % 2 != 0:
		for j in range(0, n):
			new = int(string[j])
			if j % 2 == 0 and new % 2 != 0:
				count += 1
				break
		if count == 1:
			print(1)
		else:
			print(2)
	else:
		for j in range(0, n):
			new = int(string[j])
			if j % 2 != 0 and new % 2 == 0:
				count += 1
				break
		if count == 1:
			print(2)
		else:
			print(1)


def inp():
	return int(input())

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

def minp():
	return map(int, input().split())
for _ in range(int(input())):
	n = inp()
	a = list(map(int, str(inp())))
	x = a[::2]
	y = a[1::2]
	x1 = []
	y1 = []
	for i in x:
		if i & 1:
			x1.append(i)
		else:
			y1.append(i)
	x = x1 + y1
	x1 = []
	y1 = []
	for i in y:
		if i & 1:
			x1.append(i)
		else:
			y1.append(i)
	y = y1 + x1
	if len(x) == len(y):
		if y[0] & 1:
			print(1)
		else:
			print(2)
	elif len(x) > len(y):
		if x[0] & 1:
			print(1)
		else:
			print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input()]
	if n == 1:
		if a[0] % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		even_count = len(list(filter(lambda x: x % 2 == 0, a[1::2])))
		if even_count > 0:
			print(2)
		else:
			print(1)
	else:
		odd_count = len(list(filter(lambda x: x % 2 != 0, a[::2])))
		if odd_count > 0:
			print(1)
		else:
			print(2)


t = int(input())
while t:
	n = int(input())
	num = int(input())
	if n == 1:
		if num % 2 == 0:
			print(2)
		else:
			print(1)
		t -= 1
		continue
	lst = []
	for i in str(num):
		lst.append(int(i))
	printed = False
	if n % 2 == 0:
		for i in range(len(lst)):
			if (i + 1) % 2 == 0 and lst[i] % 2 == 0:
				print(2)
				printed = True
				break
		if not printed:
			print(1)
	else:
		for i in range(len(lst)):
			if (i + 1) % 2 != 0 and lst[i] % 2 != 0:
				print(1)
				printed = True
				break
		if not printed:
			print(2)
	t -= 1


import sys
from copy import *
from bisect import *

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	n = fi()
	s = si()
	a = []
	for i in s:
		a.append(int(i))
	o = []
	e = []
	for i in range(n):
		if i % 2 == 0:
			o.append(a[i])
		else:
			e.append(a[i])
	if n == 1:
		print(1 if a[0] % 2 else 2)
	elif n % 2:
		flag = 0
		for i in o:
			if i % 2 == 1:
				flag = 1
				break
		print(2 if flag == 0 else 1)
	else:
		flag = 0
		for i in e:
			if i % 2 == 0:
				flag = 1
				break
		print(2 if flag == 1 else 1)


t = int(input())
for _ in range(t):
	keta = int(input())
	num = input()
	if keta % 2 == 0:
		gote = False
		for i in range(1, keta, 2):
			if int(num[i]) % 2 == 0:
				gote = True
		if gote:
			print(2)
		else:
			print(1)
	else:
		saki = False
		for i in range(0, keta, 2):
			if int(num[i]) % 2 == 1:
				saki = True
		if saki:
			print(1)
		else:
			print(2)


def impair(n, k):
	f = str(k)
	L = [f[i] for i in range(n) if i % 2 == 0]
	for i in L:
		if int(i) % 2 == 1:
			return True
	return False

def pair(n, k):
	f = str(k)
	L = [f[i] for i in range(n) if i % 2 == 1]
	for i in L:
		if int(i) % 2 == 0:
			return True
	return False
t = int(input())
u = 0
for u in range(t):
	n = int(input())
	k = int(input())
	if n % 2 == 0:
		if pair(n, k):
			print('2')
		else:
			print('1')
	elif impair(n, k):
		print('1')
	else:
		print('2')


for _ in range(int(input())):
	n = int(input())
	match = input()
	r = 0
	b = 0
	for i in range(n):
		if i % 2 + 1 == int(match[i]) % 2:
			r += 1
		elif i % 2 - 1 == int(match[i]) % 2:
			b += 1
	if n % 2 == 0:
		if b > 0:
			print(2)
		else:
			print(1)
	elif r > 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	s = input()
	o1 = 0
	e2 = 0
	for i in range(n):
		if i % 2:
			if not int(s[i]) % 2:
				e2 += 1
		elif int(s[i]) % 2:
			o1 += 1
	if n % 2:
		if o1 > 0:
			print(1)
		else:
			print(2)
	elif e2 > 0:
		print(2)
	else:
		print(1)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = int(input())
	if n == 1:
		if s % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		l = list(str(s))
		flagr = 0
		flagb = 0
		if n % 2 == 0:
			for i in range(1, n, 2):
				if int(l[i]) % 2 == 0:
					flagb = 1
					break
			if flagb == 1:
				print(2)
			else:
				print(1)
		else:
			for i in range(0, n, 2):
				if int(l[i]) % 2 != 0:
					flagr = 1
					break
			if flagr == 1:
				print(1)
			else:
				print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	ch = str(input())
	if n % 2:
		odd = 0
		even = 0
		for i in range(0, len(ch), 2):
			if ord(ch[i]) % 2 == 0:
				even = even + 1
			else:
				odd = odd + 1
		if odd >= 1:
			print(1)
		else:
			print(2)
	else:
		odd = 0
		even = 0
		for i in range(1, len(ch), 2):
			if ord(ch[i]) % 2 == 0:
				even = even + 1
			else:
				odd = odd + 1
		if 1 <= even:
			print(2)
		else:
			print(1)


for t in range(int(input())):
	n = int(input())
	s = input()
	if n & 1:
		f = 2
		for i in range(0, len(s), 2):
			if int(s[i]) & 1:
				f = 1
				break
	else:
		f = 1
		for i in range(1, len(s), 2):
			if not int(s[i]) & 1:
				f = 2
				break
	print(f)


ts = int(input())
for t in range(ts):
	n = int(input())
	num = int(input())
	if n == 1:
		if num % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	if n % 2 == 0:
		for i in str(num)[1::2]:
			if int(i) % 2 == 0:
				print(2)
				break
		else:
			print(1)
	else:
		for i in str(num)[::2]:
			if int(i) % 2 == 1:
				print(1)
				break
		else:
			print(2)


testcases = int(input())
while testcases:
	size = int(input())
	num = int(input())
	number = [int(x) for x in str(num)]
	if len(number) != 1:
		if len(number) % 2 == 0:
			flag = 0
			for i in range(1, len(number), 2):
				if number[i] % 2 == 0:
					print(2)
					flag = 1
					break
			if flag == 0:
				print(1)
		else:
			flag = 0
			for i in range(0, len(number), 2):
				if number[i] % 2 != 0:
					print(1)
					flag = 1
					break
			if flag == 0:
				print(2)
	elif num % 2 == 0:
		print(2)
	else:
		print(1)
	testcases -= 1


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in list(input())]
	if n % 2 == 0:
		c = 0
		i = 1
		while i < n:
			if a[i] % 2 == 0:
				c = 1
				break
			i += 2
		if c == 1:
			print(2)
		else:
			print(1)
			continue
	else:
		i = 0
		c = 0
		while i < n:
			if a[i] % 2 != 0:
				c = 1
				break
			i += 2
		if c == 1:
			print(1)
		else:
			print(2)


t = int(input())
for q in range(t):
	n = int(input())
	s = input()
	est_nch_1 = False
	est_ch_2 = False
	for i in range(n):
		if (i + 1) % 2 == 0:
			if s[i] in '02468':
				est_ch_2 = True
		elif s[i] in '13579':
			est_nch_1 = True
	if n % 2 == 1 and est_nch_1 or (n % 2 == 0 and (not est_ch_2)):
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	n = int(input())
	a = int(input())
	l = [int(x) for x in str(a)]
	rne = []
	rno = []
	bno = []
	bne = []
	for k in range(n):
		if k % 2 == 0:
			if l[k] % 2 == 0:
				rne.append(l[k])
			else:
				rno.append(l[k])
		elif l[k] % 2 == 0:
			bne.append(l[k])
		else:
			bno.append(l[k])
	if n % 2 == 0 and n != 1 and (n != 2):
		bturn = n // 2 - 1
		if len(bno) <= bturn:
			print(2)
		else:
			print(1)
	elif n % 2 != 0 and n != 1 and (n != 2):
		rturn = n // 2
		if len(rne) <= rturn:
			print(1)
		else:
			print(2)
	elif n == 1:
		if l[0] % 2 == 0:
			print(2)
		else:
			print(1)
	elif n == 2:
		if l[1] % 2 == 0:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	f = str(input())
	f = [int(i) for i in f]
	raz_od = 0
	raz_ev = 0
	va_od = 0
	va_ev = 0
	for i in range(n):
		if (i + 1) % 2 == 0:
			if f[i] % 2 == 0:
				va_ev += 1
			else:
				va_od += 1
		elif f[i] % 2 == 0:
			raz_ev += 1
		else:
			raz_od += 1
	if n == 1:
		if f[0] % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		while True:
			if raz_ev > 0:
				raz_ev -= 1
			else:
				raz_od -= 1
			if raz_od + raz_ev + va_ev + va_od == 1:
				if raz_od == 1 or va_od == 1:
					print(1)
				else:
					print(2)
				break
			if va_od > 0:
				va_od -= 1
			else:
				va_ev -= 1
			if raz_od + raz_ev + va_ev + va_od == 1:
				if raz_od == 1 or va_od == 1:
					print(1)
				else:
					print(2)
				break


t = int(input())
for i in range(t):
	n = int(input())
	narr = input()
	arr = list(narr)
	arr = [int(i) for i in arr]
	lst = []
	if n % 2 == 0:
		for i in range(1, n, 2):
			lst.append(arr[i])
		d = 0
		for i in lst:
			if i % 2 == 0:
				d += 1
		if d > 0:
			print(2)
		else:
			print(1)
	else:
		for i in range(0, n, 2):
			lst.append(arr[i])
		d = 0
		for i in lst:
			if i % 2 != 0:
				d += 1
		if d > 0:
			print(1)
		else:
			print(2)


for i in range(int(input())):
	dig = int(input())
	n = str(input())
	a = 1
	if dig == 1:
		if int(n) % 2 == 1:
			print(1)
		else:
			print(2)
	elif dig % 2 == 0:
		for i in range(1, dig, 2):
			if int(n[i]) % 2 == 0:
				print(2)
				a = 0
				break
		if a == 1:
			print(1)
	elif dig % 2 == 1:
		for i in range(0, dig, 2):
			if int(n[i]) % 2 == 1:
				print(1)
				a = 0
				break
		if a == 1:
			print(2)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().rstrip('\n\r')
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	s = list(inst())
	s = [int(i) for i in s]
	ans = 1
	if n % 2 == 0:
		for i in range(1, n + 1):
			if s[i - 1] % 2 == 0 and i % 2 == 0:
				ans = 2
				break
		else:
			ans = 1
	if n % 2 == 1:
		for i in range(1, n + 1):
			if s[i - 1] % 2 == 1 and i % 2 == 1:
				ans = 1
				break
		else:
			ans = 2
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	heuy = 0
	num = int(input())
	a = [int(x) for x in str(num)]
	if n == 1:
		if num % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		for i in range(1, n, 2):
			if a[i] % 2 == 0:
				print(2)
				heuy = 1
				break
		if heuy == 0:
			print(1)
	else:
		for i in range(0, n, 2):
			if a[i] % 2 != 0:
				print(1)
				heuy = 1
				break
		if heuy == 0:
			print(2)


for _ in range(int(input())):
	n = int(input())
	s = input()
	if n % 2 == 0:
		c = 0
		for i in range(n):
			if (i + 1) % 2 == 0:
				if int(s[i]) % 2 != 0:
					c = c + 1
		if c == n // 2:
			ans = 1
		else:
			ans = 2
	elif n == 1:
		if int(s) % 2 == 0:
			ans = 2
		else:
			ans = 1
	else:
		c = 0
		for i in range(n):
			if (i + 1) % 2 != 0:
				if int(s[i]) % 2 == 0:
					c = c + 1
			if c == n // 2 + 1:
				ans = 2
			else:
				ans = 1
	print(ans)


for i in range(int(input())):
	a = int(input())
	b = input()

	def splitc(string):
		return [char for char in string]
	try:
		b = splitc(str(b))
	except:
		b = [b]
	h = []
	j = []
	s = 1
	for u in range(len(b)):
		b[u] = int(b[u])
		if s == 1:
			h.append(b[u] % 2)
			s = 2
		else:
			j.append(b[u] % 2)
			s = 1
	if len(h) > len(j):
		if h.count(1) != 0:
			print(1)
		else:
			print(2)
	elif j.count(0) != 0:
		print(2)
	else:
		print(1)


import collections

def solution(n, x):
	(raze, breach) = (0, 0)
	for (i, d) in enumerate(str(x)):
		if i % 2 and int(float(d)) % 2 == 0:
			breach = 1
		if i % 2 == 0 and int(float(d)) % 2:
			raze = 1
	if n % 2:
		if raze:
			return 1
		else:
			return 2
	elif breach:
		return 2
	else:
		return 1
t = int(input())
for _ in range(t):
	n = int(input())
	a = int(input())
	print(solution(n, a))


for _ in range(int(input())):
	n = int(input())
	digit = input()
	result = 0
	if n % 2 == 1:
		for i in digit[0::2]:
			if int(i) % 2 == 1:
				result = 1
				break
			else:
				result = 2
	else:
		for i in digit[1::2]:
			if int(i) % 2 == 0:
				result = 2
				break
			else:
				result = 1
	print(result)


t = int(input(''))
arr = []
for i in range(t):
	input('')
	arr.append(input(''))
for i in arr:
	i = list(i)
	if len(i) == 1:
		if int(i[0]) % 2:
			print(1)
		else:
			print(2)
		continue
	if len(i) == 2:
		if int(i[1]) % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	n = len(i)
	for j in range(n):
		i[j] = int(i[j])
	if n % 2:
		flag = 0
		for j in range(n):
			if j % 2 == 0 and i[j] % 2:
				flag = 1
				break
		if flag:
			print(1)
		else:
			print(2)
	else:
		flag = 0
		for j in range(n):
			if j % 2 and i[j] % 2 == 0:
				flag = 1
		if flag:
			print(2)
		else:
			print(1)


for t in range(int(input())):
	n = int(input())
	arr = list(input())
	even = []
	odd = []
	for i in range(n):
		ele = int(arr[i])
		if i % 2 == 0:
			odd.append(ele)
		else:
			even.append(ele)
	if n % 2 == 1:
		odd_there = 0
		for i in range(len(odd)):
			if odd[i] % 2 == 1:
				odd_there += 1
				break
		if odd_there > 0:
			print(1)
		else:
			print(2)
	else:
		even_there = 0
		for i in range(len(even)):
			if even[i] % 2 == 0:
				even_there += 1
				break
		if even_there > 0:
			print(2)
		else:
			print(1)


import sys
input = sys.stdin.readline
from bisect import bisect_left
from bisect import bisect_right
from math import ceil, factorial

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k, modulus=1):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
		res %= modulus
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	s = input().strip()
	if n & 1:
		f = 0
		for i in range(0, n, 2):
			if int(s[i]) & 1:
				f = 1
				break
		if f:
			print(1)
		else:
			print(2)
	else:
		f = 0
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				f = 1
				break
		if f:
			print(2)
		else:
			print(1)


t = int(input())

def transform(x):
	if x == 0:
		return 2
	return 1
for _ in range(t):
	n = int(input())
	bin_string = input().strip()
	digits = [int(i) for i in bin_string]
	n = len(digits)
	if n == 1:
		print(transform(digits[0] % 2))
	elif n % 2 != 0:
		one_odd = False
		one_even = False
		for i in range(0, n, 2):
			if digits[i] % 2 != 0:
				one_odd = True
				break
		for i in range(1, n, 2):
			if digits[i] % 2 == 0:
				one_even = True
				break
		if one_odd:
			print(1)
		else:
			print(2)
	else:
		one_odd = False
		one_even = False
		for i in range(0, n, 2):
			if digits[i] % 2 != 0:
				one_odd = True
				break
		for i in range(1, n, 2):
			if digits[i] % 2 == 0:
				one_even = True
				break
		if one_even:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	s = input().strip()
	if n % 2:
		odd = eve = 0
		for i in range(0, n, 2):
			if int(s[i]) % 2:
				odd += 1
			else:
				eve += 1
		if odd:
			print(1)
		else:
			print(2)
	else:
		odd = eve = 0
		for i in range(1, n, 2):
			if int(s[i]) % 2:
				odd += 1
			else:
				eve += 1
		if eve:
			print(2)
		else:
			print(1)


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	a = list(input())
	k = 0
	if n % 2 == 0:
		for i in range(1, n + 1, 2):
			if int(a[i]) % 2 == 0:
				k = 2
				break
			else:
				k = 1
	elif n % 2 == 1:
		for i in range(0, n + 1, 2):
			if int(a[i]) % 2 == 1:
				k = 1
				break
			else:
				k = 2
	print(k)


for i in range(int(input())):
	n = int(input())
	s = input()
	s = list(s)
	c = 0
	d = 0
	for i in range(0, len(s)):
		if i % 2 == 0 and int(s[i]) % 2 == 1:
			c += 1
		if i % 2 == 1 and int(s[i]) % 2 == 1:
			d += 1
	if c >= 1 and n % 2 == 1:
		print(1)
	elif d == n // 2 and n % 2 == 0:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(0, t):
	m = int(input())
	str1 = input()
	neo = 0
	noo = 0
	nee = 0
	noe = 0
	for j in range(0, m):
		if j % 2 == 0:
			if int(str1[j]) % 2 == 0:
				neo += 1
			else:
				noo += 1
		elif int(str1[j]) % 2 == 0:
			nee += 1
		else:
			noe += 1
	if m % 2 == 0:
		if nee >= 1:
			ans = 2
		else:
			ans = 1
	elif noo >= 1:
		ans = 1
	else:
		ans = 2
	print(ans)


for _ in range(int(input())):
	sdf = input()
	n = int(input())
	s = str(n)
	if len(s) == 1:
		if n % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		f = 0
		if len(s) % 2 != 0:
			for i in range(0, len(s), 2):
				if i < len(s):
					if int(s[i]) % 2 != 0:
						f = 1
						print(1)
				if f == 1:
					break
			if f == 0:
				print(2)
		else:
			for j in range(1, len(s), 2):
				if j < len(s):
					if int(s[j]) % 2 == 0:
						f = 1
						print(2)
				if f == 1:
					break
			if f == 0:
				print(1)


t = int(input())
for i in range(t):
	n = int(input())
	num = input()
	if n == 1:
		if int(num) % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	odd = num[::2]
	even = num[1::2]
	if n % 2 == 0:
		ans = 1
		for j in even:
			if int(j) % 2 == 0:
				ans = 2
	else:
		ans = 2
		for j in odd:
			if int(j) % 2 == 1:
				ans = 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	count = 0
	arr = list(map(int, list(input())))
	if len(arr) % 2 != 0:
		for k in range(0, n, 2):
			if arr[k] % 2 != 0:
				print(1)
				count += 1
				break
		if count == 0:
			print(2)
	else:
		for k in range(1, n, 2):
			if arr[k] % 2 == 0:
				print(2)
				count += 1
				break
		if count == 0:
			print(1)


def to_digits(n):
	return list(map(int, str(n)))
t = int(input())
for _ in range(t):
	n = int(input())
	d = to_digits(input())
	d = list(map(lambda x: x % 2, d))
	R = d[::2]
	B = d[1::2]
	ans = None
	if n % 2 == 1:
		if 1 in R:
			ans = 1
		else:
			ans = 2
	elif 0 in B:
		ans = 2
	else:
		ans = 1
	print(ans)


def winner(num, n):
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(num[i]) % 2 == 0:
				return 2
		return 1
	else:
		for i in range(0, n, 2):
			if int(num[i]) % 2 == 1:
				return 1
		return 2
t = int(input())
while t:
	t -= 1
	n = int(input())
	num = input()
	print(winner(num, n))


for _ in range(int(input())):
	a = int(input())
	b = 0
	(c1, c2) = (0, 0)
	f = 0
	for i in input():
		b += 1
		if int(i) % 2 == 1:
			if f == 0:
				c1 = 1
		elif f == 1:
			c2 = 1
		f = (f + 1) % 2
	if b % 2 == 0:
		if c2 == 1:
			print(2)
		else:
			print(1)
	elif c1 == 1:
		print(1)
	else:
		print(2)


t = int(input())
while t > 0:
	t -= 1
	n = input()
	s = input()
	odd = 0
	even = 0
	j = 1
	for i in s:
		if int(i) % 2 != 0:
			if j % 2 != 0:
				odd += 1
		elif j % 2 == 0:
			even += 1
		j += 1
	if len(s) % 2 != 0:
		if odd != 0:
			print(1)
		else:
			print(2)
	elif even != 0:
		print(2)
	else:
		print(1)


def f():
	t = int(input())
	arr = []
	for _ in range(t):
		n = int(input())
		nums = input()
		arr.append((n, nums))
	for (n, nums) in arr:
		(even, odd) = (False, False)
		for i in range(n):
			if i % 2 and int(nums[i]) % 2 == 0:
				even = True
			elif i % 2 == 0 and int(nums[i]) % 2:
				odd = True
		if n % 2 == 0:
			if even:
				print(2)
			else:
				print(1)
		elif odd:
			print(1)
		else:
			print(2)
f()


def solution():
	n = int(input())
	s = input()
	seen = [[False, False], [False, False]]
	for i in range(n):
		seen[i % 2][int(s[i]) % 2] = True
	winner = -1
	if n % 2 == 0:
		if seen[1][0]:
			winner = 2
		else:
			winner = 1
	elif seen[0][1]:
		winner = 1
	else:
		winner = 2
	print(winner)
t = int(input())
for _ in range(t):
	solution()


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	num = int(stdin.readline())
	l = []
	r = []
	d = num % 10
	s = str(num)
	md = 0
	for i in range(1, n):
		if i % 2 == 0:
			r.append(s[i - 1])
		else:
			l.append(s[i - 1])
	if n % 2 == 0:
		if d % 2 != 0:
			for i in r:
				if int(i) % 2 == 0:
					md = -1
					break
			if md == -1:
				print(2)
			else:
				print(1)
		else:
			print(2)
	elif d % 2 == 0:
		for i in l:
			if int(i) % 2 != 0:
				md = -1
				break
		if md == -1:
			print(1)
		else:
			print(2)
	else:
		print(1)


a = int(input())
for i in range(a):
	n = int(input())
	s = input()
	ans = False
	if n % 2 == 0:
		for j in range(n):
			if int(s[j]) % 2 == 0 and j % 2 == 1:
				print(2)
				ans = True
				break
		if not ans:
			print(1)
	else:
		for j in range(n):
			if int(s[j]) % 2 != 0 and j % 2 != 1:
				print(1)
				ans = True
				break
		if not ans:
			print(2)


import sys

def solution():
	T = int(input())
	for _ in range(T):
		n = int(input())
		s = input()
		raze = s[::2]
		breach = s[1::2]
		if n % 2 == 0:
			if any((int(i) % 2 == 0 for i in breach)):
				print(2)
			else:
				print(1)
		elif any((int(i) % 2 != 0 for i in raze)):
			print(1)
		else:
			print(2)
solution()


t = int(input())

def play(n, s):
	if n % 2 == 0:
		for i in s[1::2]:
			if i % 2 == 0:
				return 2
		return 1
	else:
		for i in s[0::2]:
			if i % 2 == 1:
				return 1
		return 2
for _ in range(t):
	n = int(input())
	s = [int(c) for c in input()]
	print(play(n, s))


try:
	t = int(input())
	while t:
		s = int(input())
		n = input()
		l = [int(i) for i in n]
		(e, o) = (0, 0)
		for i in range(s):
			if i % 2 == 0:
				if l[i] % 2 == 1:
					o += 1
			if i % 2 != 0:
				if l[i] % 2 == 0:
					e += 1
		if s % 2 == 0:
			if e != 0:
				print('2')
			else:
				print('1')
		elif o != 0:
			print('1')
		else:
			print('2')
		t -= 1
except:
	pass


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	n = int(I1())
	s = I1().strip()
	if n % 2 == 0:
		f = 0
		for i in range(1, n + 1):
			if i % 2 == 0 and int(s[i - 1]) % 2 == 0:
				f = 1
				break
		if f == 1:
			print(2)
		else:
			print(1)
	else:
		f = 0
		for i in range(1, n + 1):
			if i % 2 != 0 and int(s[i - 1]) % 2 != 0:
				f = 1
				break
		if f == 1:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	r = False
	for i in range(0, n, 2):
		if int(s[i]) % 2 == 1:
			r = True
			break
	b = False
	for i in range(1, n, 2):
		if int(s[i]) % 2 == 0:
			b = True
			break
	if n % 2 == 1:
		if r:
			print(1)
		else:
			print(2)
	elif b:
		print(2)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().strip()
	if n % 2 == 0:
		f = 0
		for j in range(1, n, 2):
			if int(s[j]) % 2 == 0:
				f = 1
		if f == 1:
			print(2)
		else:
			print(1)
	else:
		f = 0
		for j in range(0, n, 2):
			if int(s[j]) % 2 != 0:
				f = 1
		if f == 0:
			print(2)
		else:
			print(1)


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	if s[n - 1] == '0':
		s.replace(s[n - 1], '')
	(odd, even) = (False, False)
	i = 1
	for i in range(n + 1):
		if i % 2 == 1:
			odd |= int(s[i - 1]) % 2 == 1
		else:
			even |= int(s[i - 1]) % 2 == 0
	if n % 2 == 1:
		if odd:
			print(1)
		else:
			print(2)
	elif even:
		print(2)
	else:
		print(1)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	arr = input()
	dico_r = 0
	dice_b = 0
	for i in range(0, len(arr), 2):
		if int(arr[i]) % 2 == 1:
			dico_r += 1
	if n % 2 == 1:
		if dico_r > 0:
			print(1)
		else:
			print(2)
	else:
		dice_b = 0
		for i in range(1, len(arr), 2):
			if int(arr[i]) % 2 == 0:
				dice_b += 1
		if dice_b > 0:
			print(2)
		else:
			print(1)


a = int(input())
for i in range(a):
	b = int(input())
	ls = []
	even = [int(i) for i in input().strip()]
	odd = even[::2]
	even = even[1::2]
	if len(odd) == 1 or len(even) == 1:
		if not odd:
			if even[0] % 2 == 0:
				print(2)
			else:
				print(1)
		if not even:
			if odd[0] % 2 == 0:
				print(2)
			else:
				print(1)
	while len(odd) + len(even) > 1:
		flag = 0
		flag2 = 0
		for i in odd:
			if i % 2 == 0:
				odd.remove(i)
				flag = 1
				break
		if flag == 0 and len(odd) + len(even) > 1:
			for i in odd:
				odd.remove(i)
				flag = 1
				break
		if flag == 1 and len(odd) + len(even) > 1:
			for i in even:
				if i % 2 != 0:
					even.remove(i)
					flag2 = 1
					break
		if flag2 == 0 and len(odd) + len(even) > 1:
			for i in even:
				even.remove(i)
				break
		if len(odd) + len(even) == 1:
			if not odd:
				if even[0] % 2 == 0:
					print(2)
				else:
					print(1)
			if not even:
				if odd[0] % 2 == 0:
					print(2)
				else:
					print(1)


for s in [*open(0)][2::2]:
	f = len(s) % 2
	print(2 - (f ^ any((f ^ 1 & int(x) for x in s[f::2]))))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	nList = list(map(int, input().rstrip()))
	flag = True
	if n % 2 == 0:
		for i in range(n):
			if i % 2 == 1 and nList[i] % 2 == 0:
				flag = False
				break
		if flag:
			print(1)
		else:
			print(2)
	else:
		for i in range(n):
			if i % 2 == 0 and nList[i] % 2 == 1:
				flag = False
				break
		if flag:
			print(2)
		else:
			print(1)


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math
import random
J = 998244353
from collections import deque
for _ in range(int(input())):
	n = int(input())
	s = input()
	if n % 2 == 0:
		c = 0
		for i in range(len(s)):
			if i % 2 == 1:
				if int(s[i]) % 2 == 0:
					c += 1
					break
		if c > 0:
			print(2)
		else:
			print(1)
	else:
		c = 0
		for i in range(len(s)):
			if i % 2 == 0:
				if int(s[i]) % 2 == 1:
					c += 1
					break
		if c > 0:
			print(1)
		else:
			print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input()))
	(r, b) = (ar[::2], ar[1::2] if n > 1 else None)
	if n % 2:
		for i in r:
			if i % 2 == 1:
				print(1)
				break
		else:
			print(2)
	else:
		for i in b:
			if i % 2 == 0:
				print(2)
				break
		else:
			print(1)


from sys import stdin
N = int(stdin.readline().strip())
for match in range(N):
	length = int(stdin.readline().strip())
	number = stdin.readline().strip()
	raze = [int(i) for i in number[::2] if int(i) % 2 == 0]
	breach = [int(i) for i in number[1::2] if int(i) % 2 == 1]
	if length % 2 == 0:
		if len(breach) == length // 2:
			print(1)
		else:
			print(2)
	elif len(raze) == length // 2 + 1:
		print(2)
	else:
		print(1)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def solution(num, n):
	if n == 1:
		if num % 2 == 0:
			return 2
		else:
			return 1
	else:
		l = []
		while num > 0:
			des = num % 10
			num = num // 10
			l.append(des)
		l = l[::-1]
		if n % 2 == 0:
			for i in range(len(l)):
				if i % 2 == 1 and l[i] % 2 == 0:
					return 2
			return 1
		else:
			for i in range(len(l)):
				if i % 2 == 0 and l[i] % 2 == 1:
					return 1
			return 2
t = inp()
while t > 0:
	n = inp()
	num = inp()
	print(solution(num, n))
	t -= 1


T = int(input())
for j in range(T):
	N = int(input())
	S = input()
	(Even_at_Odd, Even_at_Even, Odd_at_Odd, Odd_at_Even) = ([], [], [], [])
	for i in range(N):
		if int(S[i]) % 2 == 0:
			if (i + 1) % 2 == 0:
				Even_at_Even.append(int(S[i]))
			else:
				Even_at_Odd.append(int(S[i]))
		elif (i + 1) % 2 == 0:
			Odd_at_Even.append(int(S[i]))
		else:
			Odd_at_Odd.append(int(S[i]))
	Breach = Odd_at_Even + Even_at_Even
	Raze = Even_at_Odd + Odd_at_Odd
	Last_Digit = 0
	if len(Raze) > len(Breach):
		Last_Digit = Raze[-1]
	elif len(Raze) < len(Breach):
		Last_Digit = Breach[-1]
	else:
		Last_Digit = Breach[-1]
	if Last_Digit % 2 == 0:
		print(2)
	else:
		print(1)


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
for _ in range(int(input())):
	N = int(input())
	(a, b, c, d) = (0, 0, 0, 0)
	s = input()
	for i in range(N):
		if i % 2:
			if int(s[i]) % 2:
				d += 1
			else:
				c += 1
		elif int(s[i]) % 2:
			b += 1
		else:
			a += 1
	if N % 2:
		if b > 0:
			print(1)
		else:
			print(2)
	elif c > 0:
		print(2)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	num = input()
	if n % 2 == 1:
		ok = False
		for j in range(0, n, 2):
			if int(num[j]) % 2 == 1:
				ok = True
				break
		if ok:
			print(1)
		else:
			print(2)
	else:
		ok = False
		for j in range(1, n, 2):
			if int(num[j]) % 2 == 0:
				ok = True
				break
		if ok:
			print(2)
		else:
			print(1)


t = int(input())
for _ in range(t):
	dig = int(input())
	n = int(input())
	l = list(map(int, str(n)))
	l = [0] + l
	raze = []
	breach = []
	for i in range(1, dig + 1):
		if i % 2 != 0:
			raze.append(l[i])
		else:
			breach.append(l[i])
	r_even = 0
	for e in raze:
		if e % 2 == 0:
			r_even += 1
	b_odd = 0
	for e in breach:
		if e % 2 != 0:
			b_odd += 1
	if len(raze) == len(breach):
		if b_odd < len(breach):
			print(2)
		else:
			print(1)
	elif r_even < len(raze):
		print(1)
	else:
		print(2)


class digit_game:

	def __init__(self, n):
		self.digits = n
		self.count = 0

	def digit(self, num):
		num = str(num)
		for i in range(self.digits):
			if self.digits % 2 == 0:
				if i % 2 != 0 and int(num[i]) % 2 == 0:
					self.count = 1
					break
				else:
					self.count = 0
			elif i % 2 == 0 and int(num[i]) % 2 != 0:
				self.count = 0
				break
			else:
				self.count = 1
		if self.count == 1:
			print(2)
		else:
			print(1)
for tc in range(int(input())):
	n = int(input())
	num = int(input())
	result = digit_game(n)
	result.digit(num)


T = int(input())
for case in range(0, T):
	n = int(input())
	a = input()
	s1 = s2 = 0
	for i in range(0, n):
		if i % 2 == 0:
			if int(a[i]) % 2 == 1:
				s1 += 1
		elif int(a[i]) % 2 == 0:
			s2 += 1
	if n % 2 == 0:
		if s2 >= 1:
			print(2)
		else:
			print(1)
	elif s1 >= 1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	k = list(input())
	k = [int(i) for i in k]
	odd = []
	even = []
	for i in range(0, n):
		if i % 2 == 0:
			odd.append(k[i])
		else:
			even.append(k[i])
	r = 0
	if n % 2 == 0:
		for i in even:
			if i % 2 == 0:
				r = 2
				break
			else:
				r = 1
	if n % 2 == 1:
		for i in odd:
			if i % 2 == 1:
				r = 1
				break
			else:
				r = 2
	print(r)


t = int(input())
for _ in range(t):
	n = int(input())
	ara = str(input())
	if n == 1:
		if int(ara[0]) % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		l = 0
		for i in range(1, n, 2):
			if int(ara[i]) % 2 == 0:
				print('2')
				l += 1
				break
		if l == 0:
			print('1')
	elif n % 2 != 0:
		l = 0
		for i in range(0, n, 2):
			if int(ara[i]) % 2 != 0:
				print('1')
				l += 1
				break
		if l == 0:
			print('2')


for i in range(int(input())):
	list = []
	a = int(input())
	b = input()
	for i in b:
		list.append(int(i))
	Raze = list[::2]
	Breach = list[1::2]
	if len(list) == 1:
		if list[0] % 2 == 0:
			print('2')
		else:
			print('1')
	elif len(list) % 2 == 0:
		for b in Breach:
			if b % 2 == 0:
				print('2')
				break
		else:
			print('1')
	else:
		for b in Raze:
			if b % 2 == 1:
				print('1')
				break
		else:
			print('2')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for _ in range(ii()):
	n = ii()
	s = input()
	if ('1' in s[::2] or '3' in s[::2] or '5' in s[::2] or ('7' in s[::2]) or ('9' in s[::2])) and n & 1 or ('0' not in s[1::2] and '2' not in s[1::2] and ('4' not in s[1::2]) and ('6' not in s[1::2]) and ('8' not in s[1::2]) and (n % 2 == 0)):
		print(1)
	elif ('0' in s[1::2] or '2' in s[1::2] or '4' in s[1::2] or ('6' in s[1::2]) or ('8' in s[1::2])) and n % 2 == 0 or ('1' not in s[::2] and '3' not in s[::2] and ('5' not in s[::2]) and ('7' not in s[::2]) and ('9' not in s[::2]) and (n & 1)):
		print(2)


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
for _ in range(int(read())):
	n = int(read())
	num = read()
	if n == 1:
		if int(num) % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	if n % 2 == 1:
		for i in range(0, n, 2):
			if int(num[i]) % 2 == 1:
				print(1)
				break
		else:
			print(2)
	else:
		for i in range(1, n, 2):
			if int(num[i]) % 2 == 0:
				print(2)
				break
		else:
			print(1)


import math
for _ in range(int(input())):
	n = int(input())
	no = input()
	if n % 2 == 0:
		i = 1
		ans = 1
		while i < n:
			if int(no[i]) % 2 == 0:
				ans = 2
				break
			i += 2
		print(ans)
	else:
		i = 0
		ans = 2
		while i < n:
			if int(no[i]) % 2 != 0:
				ans = 1
				break
			i += 2
		print(ans)


import sys

def main():
	t = Iint()
	(first, second) = (1, 2)
	for _ in [0] * t:
		n = Iint()
		s = list(map(int, input()))
		if n % 2 == 1:
			if all((x % 2 == 0 for x in s[::2])):
				print(second)
			else:
				print(first)
		elif n % 2 == 0:
			if all((x % 2 == 1 for x in s[1::2])):
				print(first)
			else:
				print(second)
en = enumerate
FIO = 10

def debug(*args, c=6):
	pass
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=sys.stderr)
BUFSIZE = 8 * 1024

def Istr():
	return input()

def Iint():
	return int(input())

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

def Imap():
	return map(int, input().split())

def Plist(li, s=' '):
	print(s.join(map(str, li)))
if not FIO:
	if __name__ == '__main__':
		main()
		exit()
else:
	from io import BytesIO, IOBase
	import os

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))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import sys
import bisect
import math
from collections import deque
input = lambda : sys.stdin.readline().strip()
mod = 10 ** 9 + 7

def solve():
	n = int(input())
	s = input()
	if n % 2 == 0:
		for i in range(1, n, 2):
			if s[i] in ['0', '2', '4', '6', '8']:
				return 2
		return 1
	else:
		for i in range(0, n, 2):
			if s[i] in ['1', '3', '5', '7', '9']:
				return 1
		return 2
t = 1
t = int(input())
for _ in range(t):
	print(solve())


import sys
from collections import defaultdict, Counter as CC
from math import sqrt, ceil, floor, log2
INF = float('inf')
MOD = 10 ** 9 + 7
read = lambda : [int(s) for s in sys.stdin.readline().split()]

def solve():
	(n,) = read()
	s = input()
	if n % 2 == 0:
		flag = 0
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				flag = 1
		if flag:
			print(2)
		else:
			print(1)
	else:
		flag = 0
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 1:
				flag = 1
		if flag:
			print(1)
		else:
			print(2)
_ = 1
_ = int(input())
while _:
	solve()
	_ -= 1


def main():
	t = int(input())
	for _ in range(t):
		odd_idxs = [0, 0]
		even_idxs = [0, 0]
		n = int(input())
		u = input()
		for i in range(n):
			if int(u[i]) % 2 == 0:
				if i % 2 == 0:
					odd_idxs[0] += 1
				else:
					even_idxs[0] += 1
			elif i % 2 == 0:
				odd_idxs[1] += 1
			else:
				even_idxs[1] += 1
		if n % 2 == 0:
			if even_idxs[0]:
				print(2)
			else:
				print(1)
		elif odd_idxs[1]:
			print(1)
		else:
			print(2)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	if n & 1:
		ans = 2
		for (p, i) in enumerate(s):
			if int(i) & 1 and p & 1 == 0:
				ans = 1
				break
		print(ans)
	else:
		ans = 1
		for (p, i) in enumerate(s):
			if int(i) & 1 == 0 and p & 1:
				ans = 2
				break
		print(ans)


t = int(input())
ans = []
for k in range(t):
	n = int(input())
	c = list(map(int, input()))
	b = []
	r = []
	for i in range(n):
		if i % 2 == 1:
			b.append(c[i])
		elif i % 2 == 0:
			r.append(c[i])
	if n % 2 == 0:
		f1 = False
		for x in b:
			if x % 2 == 0:
				f1 = True
				break
		if f1:
			ans.append(2)
		else:
			ans.append(1)
	else:
		f1 = False
		for x in r:
			if x % 2 == 1:
				f1 = True
				break
		if f1:
			ans.append(1)
		else:
			ans.append(2)
for i in ans:
	print(i)


for i in range(int(input())):
	n = int(input())
	n_l = input()
	if n > 1:
		if n % 2 == 0:
			ans = 1
			for j in range(1, n, 2):
				if int(n_l[j]) % 2 == 0:
					ans = 2
					break
			print(ans)
		else:
			ans = 2
			for j in range(0, n, 2):
				if int(n_l[j]) % 2 != 0:
					ans = 1
					break
			print(ans)
	elif int(n_l[-1]) % 2 == 0:
		print(2)
	else:
		print(1)


t = int(input())
for k in range(t):
	n = int(input())
	num = input()
	odd = 0
	even = 0
	for i in range(0, n):
		if (i + 1) % 2 == 1 and int(num[i]) % 2 == 1:
			odd = 1
		elif (i + 1) % 2 == 0 and int(num[i]) % 2 == 0:
			even = 1
	if n % 2 == 0:
		if even == 1:
			print(2)
		else:
			print(1)
	elif odd == 1:
		print(1)
	else:
		print(2)


def answer(n, A):
	if n % 2 == 0:
		count = 0
		for i in range(1, n, 2):
			if int(A[i]) % 2 == 0:
				count += 1
		if count >= 1:
			return 2
		else:
			return 1
	else:
		count = 0
		for i in range(0, n, 2):
			if int(A[i]) % 2 != 0:
				count += 1
		if count >= 1:
			return 1
		else:
			return 2
t = int(input())
for i in range(t):
	n = int(input())
	A = list(input())
	print(answer(n, A))


def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
for i in range(n):
	m = inp()
	even = []
	odd = []
	x = insr()
	c = 0
	odd_count = 0
	odd_odd = 0
	even_even = 0
	while c < len(x):
		if c % 2 == 0 and int(x[c]) % 2 == 1:
			odd_odd += 1
		elif c % 2 == 1 and int(x[c]) % 2 == 0:
			even_even += 1
		c += 1
	if m % 2 == 1:
		if odd_odd > 0:
			print(1)
		else:
			print(2)
	elif even_even > 0:
		print(2)
	else:
		print(1)


for test in range(int(input())):
	n = int(input())
	l = input()
	f = 0
	if n % 2 == 0:
		for i in range(n):
			if (i + 1) % 2 == 0 and int(l[i]) % 2 == 0:
				f = 1
				break
		if f == 1:
			print(2)
		else:
			print(1)
	else:
		for i in range(n):
			if (i + 1) % 2 == 1 and int(l[i]) % 2 == 1:
				f = 1
				break
		if f == 1:
			print(1)
		else:
			print(2)


z = int(input())
for i in range(z):
	n = int(input())
	s = input()
	x = 0
	if n % 2:
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 0:
				x += 1
		if x == (n + 1) // 2:
			print(2)
		else:
			print(1)
	else:
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 1:
				x += 1
		if x == n // 2:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(0, t):
	n = int(input())
	num = input()
	arr = [int(x) for x in str(num)]
	c = 0
	if n % 2 == 0:
		for i in range(len(arr)):
			if i % 2 != 0 and arr[i] % 2 == 0:
				c = 2
		if c == 2:
			print(c)
		else:
			print('1')
	else:
		for i in range(len(arr)):
			if i % 2 == 0 and arr[i] % 2 != 0:
				c = 1
		if c == 1:
			print(c)
		else:
			print('2')


for _ in range(int(input())):
	n = int(input())
	s = input()
	r = 0
	b = 0
	c_even = 0
	c_odd = 0
	for i in range(len(s)):
		if int(s[i]) % 2 == 0:
			c_even += 1
		else:
			c_odd += 1
		if i % 2 == 0:
			if int(s[i]) % 2 != 0:
				r = 1
		elif int(s[i]) % 2 == 0:
			b = 1
	if c_even == len(s):
		print('2')
	elif c_odd == len(s):
		print('1')
	elif len(s) % 2 == 0 and b == 1:
		print('2')
	elif len(s) % 2 == 0 and b != 1:
		print('1')
	elif len(s) % 2 != 0 and r == 1:
		print('1')
	else:
		print('2')


for t in range(int(input())):
	n = int(input())
	s = input()
	(a, b) = ([], [])
	for i in range(len(s)):
		if i % 2 == 0:
			a.append(int(s[i]) % 2)
		else:
			b.append(int(s[i]) % 2)
	if len(s) % 2 != 0:
		if a.count(1) > 0:
			print(1)
		else:
			print(2)
	elif b.count(0) > 0:
		print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = [int(x) for x in list(input())]
	odd = sorted([l1[i] % 2 for i in range(len(l1)) if i % 2 == 0])
	even = sorted([l1[i] % 2 for i in range(len(l1)) if i % 2], reverse=True)
	if n % 2 == 0:
		if even[-1] == 1:
			print(1)
		else:
			print(2)
	elif sum(odd):
		print(1)
	else:
		print(2)


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * (2 * 10 ** 5 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(2 * 10 ** 5 + 5):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj
mod = 10 ** 9 + 7

def solve():
	n = II()
	num = str(II())
	if n % 2 == 0:
		for i in range(1, len(num), 2):
			if int(num[i]) % 2 == 0:
				print(2)
				return
		print(1)
		return
	else:
		for i in range(0, len(num), 2):
			if int(num[i]) % 2:
				print(1)
				return
		print(2)
		return
t = II()
for i in range(t):
	solve()


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	s = input().strip()
	if n % 2 == 0:
		flg = False
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				flg = True
		if flg:
			print(2)
		else:
			print(1)
	else:
		flg = False
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 1:
				flg = True
		if flg:
			print(1)
		else:
			print(2)
for _ in range(int(input())):
	main()


import sys, math
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	s = input()
	if n % 2 == 0:
		ans = 1
		for i in range(n):
			if i % 2 != 0 and int(s[i]) % 2 == 0:
				ans = 2
				break
		print(ans)
	else:
		ans = 2
		for i in range(n):
			if i % 2 != 1 and int(s[i]) % 2 == 1:
				ans = 1
				break
		print(ans)


def has_odd_in_odd(s):
	for i in range(0, len(s), 2):
		if s[i] in '13579':
			return True
	return False

def has_even_in_even(s):
	for i in range(1, len(s), 2):
		if s[i] in '02468':
			return True
	return False
t = int(input())
for i in range(t):
	n = int(input())
	num = input()
	if n % 2 == 0:
		if has_even_in_even(num):
			print(2)
		else:
			print(1)
	elif has_odd_in_odd(num):
		print(1)
	else:
		print(2)


def translation():
	word_1 = input()
	word_2 = input()[::-1]
	print(['NO', 'YES'][word_1 == word_2])
	return

def anton_and_danik():
	games = int(input())
	wins = input()
	anton_wins = sum((i == 'A' for i in wins))
	if anton_wins * 2 > len(wins):
		print('Anton')
	elif anton_wins * 2 == len(wins):
		print('Friendship')
	else:
		print('Danik')
	return

def acoomodation():
	cnt = 0
	for _ in range(int(input())):
		(p, q) = map(int, input().split())
		if q - p >= 2:
			cnt += 1
	print(cnt)
	return

def juicer():
	(n, b, d) = map(int, input().split())
	sum_orange = 0
	cnt_empty = 0
	for orange in list(map(int, input().split())):
		if orange <= b:
			sum_orange += orange
			if sum_orange > d:
				cnt_empty += 1
				sum_orange = 0
	print(cnt_empty)
	return

def digit_game():
	for game in range(int(input())):
		breach_odd_cnt = 0
		breach_even_cnt = 0
		raze_odd_cnt = 0
		raze_even_cnt = 0
		n = int(input())
		number = input()
		breach_numbers = ''
		raze_numbers = ''
		len_number = len(number)
		idx = 1
		for digit in number:
			if idx % 2 == 0:
				breach_numbers += digit
				if digit in '13579':
					breach_odd_cnt += 1
				else:
					breach_even_cnt += 1
			else:
				raze_numbers += digit
				if digit in '13579':
					raze_odd_cnt += 1
				else:
					raze_even_cnt += 1
			idx += 1
		if len_number == 1:
			if int(number) % 2 == 0:
				print(2)
			else:
				print(1)
		elif len_number % 2 == 0:
			if breach_even_cnt >= 1:
				print(2)
			else:
				print(1)
		elif raze_odd_cnt >= 1:
			print(1)
		else:
			print(2)
	return
digit_game()


def solve():
	num = int(input())
	n = input()
	if len(n) % 2 == 1:
		for i in range(0, len(n), 2):
			if int(n[i]) % 2 == 1:
				print(1)
				return
		print(2)
	else:
		for i in range(1, len(n), 2):
			if int(n[i]) % 2 == 0:
				print(2)
				return
		print(1)

def main():
	T = int(input())
	for _ in range(T):
		solve()
main()


import sys
T = int(input())
for _ in range(T):
	N = int(input())
	s = input()
	flag = 1
	if N % 2 == 0:
		for i in range(1, N, 2):
			if int(s[i]) % 2 == 0:
				flag = 2
				break
	else:
		flag = 2
		for i in range(0, N, 2):
			if int(s[i]) % 2 != 0:
				flag = 1
				break
	print(flag)


t = int(input())
for game in range(t):
	n = int(input())
	num = list(map(int, input()))
	As = [num[i] for i in range(n) if i % 2 == 0]
	Bs = [num[i] for i in range(n) if i % 2 != 0]
	if n == 1:
		if num[0] % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		if any([number % 2 == 0 for number in Bs]):
			print(2)
		else:
			print(1)
	elif n % 2 != 0:
		if any([number % 2 != 0 for number in As]):
			print(1)
		else:
			print(2)


import math
t = int(input())
while t:
	n = int(input())
	s = 'a' + input()
	(even, odd) = (0, 0)
	for i in range(1, n + 1):
		if i % 2 == n % 2:
			even += int(s[i]) % 2 == 0
			odd += int(s[i]) % 2 == 1
	if n % 2 == 0:
		if even > 0:
			print(2)
		else:
			print(1)
	elif odd > 0:
		print(1)
	else:
		print(2)
	t -= 1


def solve(n, d):
	d = [int(x) for x in d]
	brim_even = list()
	brim_odd = list()
	raze_even = list()
	raze_odd = list()
	for i in range(1, len(d) + 1):
		if i % 2 == 0:
			if d[i - 1] % 2 == 0:
				brim_even.append(d[i - 1])
			else:
				brim_odd.append(d[i - 1])
		elif d[i - 1] % 2 == 0:
			raze_even.append(d[i - 1])
		else:
			raze_odd.append(d[i - 1])
	raze_even.extend(raze_odd)
	brim_odd.extend(brim_even)
	for i in range(0, len(d) - 1):
		if i % 2 == 0:
			if len(raze_even) != 0:
				raze_even.pop(0)
		elif len(brim_odd) != 0:
			brim_odd.pop(0)
	if len(raze_even) == 1:
		if raze_even[-1] % 2 == 0:
			print('2')
		else:
			print('1')
	elif len(brim_odd) == 1:
		if brim_odd[-1] % 2 == 0:
			print('2')
		else:
			print('1')

def main():
	for i in range(int(input())):
		n = input()
		solve(n, input())
main()


nums = []
for i in range(int(input())):
	nums.append([int(input())])
	nums[-1].append(int(input()))
for i in nums:
	lenN = i[0]
	listN = list(str(i[1]))
	rayze = [0, 0]
	breach = rayze[:]
	for j in range(lenN):
		n = int(listN[j])
		nc = n % 2
		jnc = j % 2
		if not jnc:
			if nc:
				rayze[1] += 1
			else:
				rayze[0] += 1
		elif nc:
			breach[0] += 1
		else:
			breach[1] += 1
	while lenN not in [1, 2]:
		if rayze[0] != 0:
			rayze[0] -= 1
		else:
			rayze[1] -= 1
		if breach[0] != 0:
			breach[0] -= 1
		else:
			breach[1] -= 1
		lenN -= 2
	if lenN == 2:
		if rayze[0]:
			rayze[0] -= 1
		else:
			rayze[1] -= 1
	if rayze[1] or breach[0]:
		result = 1
	else:
		result = 2
	print(result)


for _ in range(int(input())):
	d = int(input())
	n = input()
	if d == 1:
		if int(n[0]) % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		c = 0
		(oe, oo, eo, ee) = (0, 0, 0, 0)
		for i in range(d):
			c += 1
			if int(n[i]) % 2 == 0:
				if c % 2 == 0:
					ee += 1
				else:
					oe += 1
			elif c % 2 == 0:
				eo += 1
			else:
				oo += 1
		t = 0
		while t < d - 1:
			t += 1
			if t % 2 != 0:
				if oe > 0:
					oe -= 1
				elif oo > 0:
					oo -= 1
			elif eo > 0:
				eo -= 1
			elif ee > 0:
				ee -= 1
		if ee > 0 or oe > 0:
			print(2)
		elif oo > 0 or eo > 0:
			print(1)


def digitGame(num, n):
	st = str(num)
	check = 0
	ev = []
	od = []
	for i in range(n):
		if check == 0:
			od.append(int(st[i]))
			check = 1
		else:
			ev.append(int(st[i]))
			check = 0
	flag = 0
	if n % 2 == 0:
		for i in ev:
			if i % 2 == 0:
				flag = 2
				break
		if flag == 0:
			flag = 1
	else:
		flag = 0
		for i in od:
			if i % 2 != 0:
				flag = 1
				break
		if flag == 0:
			flag = 2
	if flag == 1:
		return 1
	elif flag == 2:
		return 2
t = int(input())
for i in range(t):
	n = int(input())
	num = int(input())
	print(digitGame(num, n))


from sys import stdin, stdout, maxsize
import math
R = lambda : stdin.readline().strip()
RL = lambda f=None: list(map(f, R().split(' '))) if f else list(R().split(' '))
output = lambda x: stdout.write(str(x) + '\n')
output_list = lambda x: output(' '.join(map(str, x)))
for t in range(int(R())):
	n = int(R())
	num = list(map(int, list(R())))
	cnt = [0, 0]
	for i in range(n):
		if (i + 1) % 2:
			cnt[0] |= num[i] % 2
		else:
			cnt[1] |= not num[i] % 2
	if n % 2:
		if cnt[0]:
			output(1)
		else:
			output(2)
	elif cnt[1]:
		output(2)
	else:
		output(1)


def read_ints():
	return map(int, input().split())

def read_int():
	return int(input())
T = read_int()
for _ in range(T):
	n = read_int()
	s = list(map(int, str(input())))
	razeHasOdd = False
	breachHasEven = False
	for (i, v) in enumerate(s):
		if i % 2 == 0 and v % 2 == 1:
			razeHasOdd = True
		if i % 2 == 1 and v % 2 == 0:
			breachHasEven = True
	razePlaysLast = n % 2 == 0
	if razePlaysLast:
		if breachHasEven:
			print(2)
		else:
			print(1)
	elif razeHasOdd:
		print(1)
	else:
		print(2)


y122 = int(input())
for __ in range(y122):
	k = int(input())
	n = list(input())
	r = k % 2
	if r == 1:
		t = 0
		for i in range(0, len(n), 2):
			if int(n[i]) % 2 == r:
				print(1)
				t += 1
				break
		if t == 0:
			print(2)
	else:
		t = 0
		for i in range(1, len(n), 2):
			if int(n[i]) % 2 == r:
				print(2)
				t += 1
				break
		if t == 0:
			print(1)


T = int(input())
for Tid in range(T):
	n = int(input())
	s = input()
	(f1, f2) = (0, 0)
	for i in range(n):
		if (i + n) % 2 == 1:
			if int(s[i]) % 2 == 1:
				f1 = 1
			else:
				f2 = 1
	if n % 2 == 0:
		if f2:
			print(2)
		else:
			print(1)
	elif f1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	if n == 1:
		if int(input()) % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		flag = 0
		l = list(input())
		if n % 2 != 0:
			for i in range(len(l)):
				if (i + 1) % 2 != 0:
					if int(l[i]) % 2 != 0:
						flag = 1
						break
			if flag:
				print(1)
			else:
				print(2)
		else:
			for i in range(len(l)):
				if (i + 1) % 2 == 0:
					if int(l[i]) % 2 == 0:
						flag = 1
						break
			if flag:
				print(2)
			else:
				print(1)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def ceil(x, y=1):
	return int(-(-x // y))
import math
from collections import defaultdict
for _ in range(ri()):
	n = ri()
	l = [int(i) for i in list(input())]
	if n == 1:
		if l[0] & 1:
			wi(1)
		else:
			wi(2)
	else:
		e = o = e_o = e_e = o_e = o_o = 0
		for i in range(n):
			if i + 1 & 1:
				o += 1
				if l[i] & 1:
					o_o += 1
				else:
					o_e += 1
			else:
				e += 1
				if l[i] & 1:
					e_o += 1
				else:
					e_e += 1
		if o == e:
			if e_e > 0:
				wi(2)
			else:
				wi(1)
		elif o > e:
			if o_o > 0:
				wi(1)
			else:
				wi(2)
		elif e_e > 0:
			wi(2)
		else:
			wi(1)


def chg(s):
	even = ''
	odd = ''
	for i in range(len(s)):
		if int(s[i]) % 2 == 0:
			even += s[i]
		else:
			odd += s[i]
	s = even + odd
	return s

def chn(s):
	even = ''
	odd = ''
	for i in range(len(s)):
		if int(s[i]) % 2 == 0:
			even += s[i]
		else:
			odd += s[i]
	s = odd + even
	return s

def rearrange(s, n):
	if n == 1:
		if int(s) % 2 == 0:
			return 2
		return 1
	odpos = ''
	evenpos = ''
	for i in range(len(s)):
		if (i + 1) % 2 == 0:
			evenpos += s[i]
		else:
			odpos += s[i]
	s1 = chg(odpos)
	s2 = chn(evenpos)
	if len(s1) == len(s2):
		if int(s2[-1]) % 2 == 0:
			return 2
		else:
			return 1
	elif int(s1[-1]) % 2 == 0:
		return 2
	else:
		return 1
t = int(input())
for _ in range(t):
	n = int(input())
	m = input()
	print(rearrange(m, n))


t = int(input())
for _ in range(t):
	n = int(input())
	k = int(input())
	if n == 1:
		if k % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		lst = list(str(k))
		ans = False
		for c in range(1, n, 2):
			if int(lst[c]) % 2 == 0:
				ans = True
				break
		if ans:
			print(2)
		else:
			print(1)
	else:
		lst = list(str(k))
		ans = False
		for c in range(0, n, 2):
			if int(lst[c]) % 2 != 0:
				ans = True
				break
		if ans:
			print(1)
		else:
			print(2)


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
sys.setrecursionlimit(10 ** 5)

def mod():
	return 10 ** 9 + 7

def i():
	return sys.stdin.readline().strip()

def ii():
	return int(sys.stdin.readline())

def li():
	return list(sys.stdin.readline().strip())

def mii():
	return map(int, sys.stdin.readline().split())

def lii():
	return list(map(int, sys.stdin.readline().strip().split()))

def solve():
	a = ii()
	b = li()
	oo = ee = eo = oe = 0
	for i in range(a):
		if int(b[i]) % 2 == 0 and i % 2 == 0:
			oe += 1
		elif int(b[i]) % 2 == 1 and i % 2 == 0:
			oo += 1
		elif int(b[i]) % 2 == 0 and i % 2 == 1:
			ee += 1
		else:
			eo += 1
	if a % 2 == 0:
		if ee > 0:
			print(2)
		else:
			print(1)
	elif oo > 0:
		print(1)
	else:
		print(2)
for _ in range(ii()):
	solve()


from math import inf, sqrt, floor, ceil
from collections import Counter, defaultdict, deque
from heapq import heappush as hpush, heappop as hpop, heapify as h
from operator import itemgetter
from itertools import product
from bisect import bisect_left, bisect_right
for _ in range(int(input())):
	n = int(input())
	s = input()
	(o, e) = (0, 0)
	for i in range(0, n, 2):
		if int(s[i]) & 1:
			o = 1
			break
	for i in range(1, n, 2):
		if not int(s[i]) & 1:
			e = 1
			break
	if n & 1:
		if o:
			print(1)
		else:
			print(2)
	elif e:
		print(2)
	else:
		print(1)


num_matches = int(input())
for match in range(num_matches):
	N = int(input())
	X = [int(i) for i in input()]
	if N == 1:
		if X[0] % 2 == 0:
			print('2')
		else:
			print('1')
		continue
	n_e = 0
	n_o = 0
	for i in range(N):
		if (i + 1) % 2 == 0 and X[i] % 2 == 0:
			n_e += 1
		elif (i + 1) % 2 != 0 and X[i] % 2 != 0:
			n_o += 1
	if N % 2 == 0:
		if n_e > 0:
			print('2')
		else:
			print('1')
	elif N % 2 != 0:
		if n_o > 0:
			print('1')
		else:
			print('2')


n = int(input())
while n:
	x = int(input())
	y = input()
	e = 0
	o = 0
	if x == 1:
		if int(y) % 2 == 0:
			print('2')
		else:
			print('1')
	else:
		for i in range(x):
			if int(y[i]) % 2 == 0 and (i + 1) % 2 == 0:
				e = 1
			elif int(y[i]) % 2 != 0 and (i + 1) % 2 != 0:
				o = 1
		if x % 2 == 0:
			if e == 1:
				print('2')
			else:
				print('1')
		elif o == 1:
			print('1')
		else:
			print('2')
	n -= 1


from sys import stdin
from math import ceil, gcd
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = stdin.readline().strip()
	(r_e, b_e) = (0, 0)
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2 == 0:
				r_e += 1
		elif int(s[i]) % 2 == 0:
			b_e += 1
	b_chances = n // 2
	r_chances = n - b_chances
	if n % 2 == 0:
		if b_e > 0:
			print(2)
		else:
			print(1)
	elif r_chances - r_e > 0:
		print(1)
	else:
		print(2)


from sys import stdin, stdout

class Input:

	def __init__(self):
		self.lines = stdin.read().splitlines()
		self.idx = 0

	def line(self):
		try:
			return self.lines[self.idx]
		finally:
			self.idx += 1

	def array(self, sep=' ', cast=int):
		return list(map(cast, self.line().split(sep=sep)))

	def known_tests(self):
		(num_of_cases,) = self.array()
		for case in range(num_of_cases):
			yield self

	def unknown_tests(self):
		while self.idx < len(self.lines):
			yield self

class Problem:

	def __init__(self):
		self.oo = float('inf')

	def gcd(self, a, b):
		return a if b == 0 else self.gcd(b, a % b)

	def modpow(self, a, n, m):
		ans = 1
		while n:
			if n & 1:
				ans = ans * a % m
			n >>= 1
			a = a * a % m
		return ans

	def solve(self, n, digits):
		odd = [0, 0]
		even = [0, 0]
		for i in range(len(digits)):
			d = int(digits[i])
			if i % 2 == 0:
				odd[d % 2] += 1
			else:
				even[d % 2] += 1
		if n % 2 == 0:
			print(2 if even[0] else 1)
		else:
			print(1 if odd[1] else 2)
try:
	p = Problem()
	for tc in Input().known_tests():
		p.solve(*tc.array(), tc.line())
except Exception as e:
	import traceback
	traceback.print_exc(file=stdout)


for i in range(int(input())):
	input()
	n = input()
	if len(n) % 2 == 0:
		b = False
		for el in n[1::2]:
			if int(el) % 2 == 0:
				print(2)
				b = True
				break
		if not b:
			print(1)
	elif len(n) % 2 != 0:
		b = False
		for el in n[::2]:
			if int(el) % 2 != 0:
				print(1)
				b = True
				break
		if not b:
			print(2)


from sys import stdin, stdout, setrecursionlimit
import heapq
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007
tc = ii1()
for _ in range(tc):
	n = ii1()
	s = is1()
	(beven, bodd) = ([], [])
	(reven, rodd) = ([], [])
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2 == 0:
				beven.append(int(s[i]))
			else:
				bodd.append(int(s[i]))
		elif int(s[i]) % 2 == 0:
			reven.append(int(s[i]))
		else:
			rodd.append(int(s[i]))
	flag = 1
	while len(beven + bodd + reven + rodd) > 1:
		if flag == 1:
			if len(beven):
				beven.pop()
			else:
				bodd.pop()
		elif len(rodd):
			rodd.pop()
		else:
			reven.pop()
		flag ^= 1
	if len(beven) or len(reven):
		print(2)
	else:
		print(1)


T = int(input())

def solve():
	N = int(input())
	L = input()
	Raze = {0: 0, 1: 0}
	Breach = {0: 0, 1: 0}
	for i in range(N):
		if i % 2 == 0:
			if int(L[i]) % 2 == 0:
				Raze[0] += 1
			else:
				Raze[1] += 1
		elif int(L[i]) % 2 == 0:
			Breach[0] += 1
		else:
			Breach[1] += 1
	if N % 2 == 0:
		if Breach[0] > 0:
			print(2)
		else:
			print(1)
	elif Raze[1] > 0:
		print(1)
	else:
		print(2)
for i in range(T):
	solve()


n = int(input())
for i in range(n):
	n1 = int(input())
	c = input()
	k1 = 0
	k2 = 0
	if n1 % 2 == 0:
		for j in range(1, len(c), 2):
			if int(c[j]) % 2 == 0:
				k1 = 1
				break
		if k1 == 1:
			print('2')
		else:
			print('1')
	else:
		for j in range(0, len(c), 2):
			if int(c[j]) % 2 != 0:
				k2 = 1
				break
		if k2 == 1:
			print('1')
		else:
			print('2')


T = int(input())
while T > 0:
	T -= 1
	n = int(input())
	s = str(input())
	razeHasOdd = False
	breachHasEven = False
	odd = True
	for c in s:
		if odd:
			if int(c) % 2 == 1:
				razeHasOdd = True
			odd = False
		else:
			odd = True
			if int(c) % 2 == 0:
				breachHasEven = True
	res = 0
	if n % 2 == 1:
		if razeHasOdd:
			res = 1
		else:
			res = 2
	elif breachHasEven:
		res = 2
	else:
		res = 1
	print(res)


t = int(input())
ans_array = []
e = ['0', '2', '4', '6', '8']
o = ['1', '3', '5', '7', '9']

def Match():
	n = int(input())
	number = int(input())
	odd = ''
	even = ''
	ans = 0
	stro = str(number)
	for i in range(n):
		temp = stro[i]
		if i % 2 == 0:
			odd += temp
		else:
			even += temp
	if n % 2 == 0:
		for j in range(len(even)):
			if even[j] in e:
				ans = 2
				break
			else:
				ans = 1
	else:
		for j in range(len(odd)):
			if odd[j] in o:
				ans = 1
				break
			else:
				ans = 2
	ans_array.append(ans)
for i in range(t):
	Match()
for i in range(t):
	print(ans_array[i])


t = int(input())
for _ in range(t):
	N = int(input())
	a = input()
	st = N % 2
	l = 1
	for i in range(1 - st, N, 2):
		l &= (int(a[i]) + st) % 2
	if st:
		print(1 + l)
	else:
		print(2 - l)


t = int(input())
for _ in range(t):
	n = int(input())
	digit = input()
	raze = list()
	breach = list()
	if n == 1:
		if int(digit) % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	for i in range(n):
		if (i + 1) % 2 == 0:
			breach.append(int(digit[i]))
		else:
			raze.append(int(digit[i]))
	evenCount = 0
	oddCount = 0
	for i in raze:
		if i % 2 == 1:
			oddCount += 1
	for i in breach:
		if i % 2 == 0:
			evenCount += 1
	if n % 2 == 1:
		if oddCount > 0:
			print(1)
		else:
			print(2)
	elif evenCount > 0:
		print(2)
	else:
		print(1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	x = str(int(input()))
	if n % 2 == 0:
		even = False
		for i in range(n):
			if i % 2 and int(x[i]) % 2 == 0:
				even = True
				break
		if even:
			print(2)
		else:
			print(1)
	else:
		odd = False
		for i in range(n):
			if i % 2 == 0 and int(x[i]) % 2:
				odd = True
				break
		if odd:
			print(1)
		else:
			print(2)


def get_int():
	return int(input())
for t in range(0, get_int()):
	n = get_int()
	digits = [int(c) for c in input()]
	if n % 2 == 0:
		win = False
		for i in range(1, len(digits), 2):
			if digits[i] % 2 == 0:
				win = True
		if win:
			print(2)
		else:
			print(1)
	else:
		win = False
		for i in range(0, len(digits), 2):
			if digits[i] % 2 == 1:
				win = True
		if win:
			print(1)
		else:
			print(2)


from collections import defaultdict as dd
from sys import stdin, stdout
from bisect import bisect_left
from math import log, sqrt
for t in range(int(stdin.readline().strip())):
	n = int(stdin.readline().strip())
	a = list(map(int, input()))
	if n == 1:
		if a[0] & 1:
			print(1)
		else:
			print(2)
		continue
	e = []
	o = []
	for i in range(n):
		if i & 1:
			e.append(a[i])
		else:
			o.append(a[i])
	if n & 1:
		flag = False
		for i in o:
			if i & 1:
				flag = True
				break
		if flag:
			print(1)
			continue
		else:
			print(2)
			continue
	else:
		flag = False
		for i in e:
			if not i & 1:
				flag = True
				break
		if flag:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	s = str(input())
	(oodd, eeven) = (0, 0)
	for i in range(1, n + 1):
		if i & 1:
			if int(s[i - 1]) & 1:
				oodd += 1
		elif not int(s[i - 1]) & 1:
			eeven += 1
	if n & 1:
		if oodd > 0:
			print(1)
		else:
			print(2)
	elif eeven > 0:
		print(2)
	else:
		print(1)


for i in range(int(input())):
	m = int(input())
	n = input()
	r = ''
	b = ''
	if m == 1 and int(n) % 2 == 0:
		print(2)
	elif m == 1 and int(n) % 2 != 0:
		print(1)
	else:
		for i in range(m):
			if i % 2 == 0:
				r = r + n[i]
			else:
				b = b + n[i]
		if m % 2 == 0:
			for i in b:
				if int(i) % 2 == 0:
					print(2)
					break
			else:
				print(1)
		else:
			for i in r:
				if int(i) % 2 != 0:
					print(1)
					break
			else:
				print(2)


t = int(input())
while t > 0:
	d = int(input())
	n = input()
	if d == 1:
		if int(n) % 2 == 0:
			print('2')
		else:
			print('1')
	elif d % 2 == 0:
		l = [int(n[i]) for i in range(len(n)) if i % 2 != 0 and int(n[i]) % 2 != 0]
		if len(l) < d // 2:
			print('2')
		else:
			print('1')
	elif d % 2 != 0:
		l = [int(n[i]) for i in range(len(n)) if i % 2 == 0 and int(n[i]) % 2 == 0]
		if len(l) <= d // 2:
			print('1')
		else:
			print('2')
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	m = list(input())
	if n % 2 == 0:
		count = 0
		for i in range(len(m)):
			if (i + 1) % 2 == 0 and int(m[i]) % 2 == 0:
				count += 1
		if count > 0:
			print(2)
		else:
			print(1)
	if n % 2 != 0:
		count = 0
		for i in range(len(m)):
			if (i + 1) % 2 != 0 and int(m[i]) % 2 != 0:
				count += 1
		if count > 0:
			print(1)
		else:
			print(2)


test = int(input())
while test:
	n = int(input())
	str = input()
	odd = map(int, str[0::2])
	even = map(int, str[1::2])
	oc = 0
	ec = 0
	if n % 2 == 0:
		for i in even:
			if i % 2 == 0:
				ec += 1
				break
		if ec > 0:
			print(2)
		else:
			print(1)
	else:
		for i in odd:
			if i % 2 == 1:
				oc += 1
				break
		if oc > 0:
			print(1)
		else:
			print(2)
	test -= 1


def f():
	n = int(input())
	A = [int(s) for s in input()]
	if n % 2:
		for i in range(0, n, 2):
			if A[i] % 2:
				print(1)
				return
		print(2)
		return
	else:
		for i in range(1, n, 2):
			if not A[i] % 2:
				print(2)
				return
		print(1)
		return
for t in range(int(input())):
	f()


def winner(length, num):
	digits = list(str(num))
	raze = [int(digits[i]) for i in range(0, length, 2)]
	breach = [int(digits[i]) for i in range(1, length, 2)]
	if length % 2 == 1:
		for i in raze:
			if i % 2 == 1:
				print('1')
				return
		print('2')
		return
	else:
		for i in breach:
			if i % 2 == 0:
				print('2')
				return
		print('1')
		return
t = int(input())
for _ in range(t):
	length = int(input())
	num = int(input())
	winner(length, num)
pass


import math
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, (char for char in input())))
	if n % 2 == 0:
		if any((a[i - 1] % 2 == 0 for i in range(1, n + 1) if i % 2 == 0)):
			print('2')
		else:
			print('1')
	elif any((a[i - 1] % 2 == 1 for i in range(1, n + 1) if i % 2 == 1)):
		print('1')
	else:
		print('2')
	t -= 1


t = int(input())
while t:
	n = int(input())
	num = int(input())
	t -= 1
	if n % 2 == 1:
		c = 1
		while True:
			if num % 10 % 2 == 1:
				print(1)
				c = 0
				break
			num //= 100
			if num == 0:
				break
		if c:
			print(2)
	else:
		c = 1
		while True:
			if num % 10 % 2 == 0:
				print(2)
				c = 0
				break
			num //= 100
			if num == 0:
				break
		if c:
			print(1)


t = int(input())
for i in range(t):
	n = int(input())
	num = input()
	raze = []
	breach = []
	for j in range(n):
		if (n - j - 1) % 2 == 0:
			raze.append(int(num[n - j - 1]))
		else:
			breach.append(int(num[n - j - 1]))
	flg = 0
	if n % 2 == 0:
		for k in breach:
			if k % 2 == 0:
				print(2)
				flg = 1
				break
		if flg == 0:
			print(1)
	else:
		for l in raze:
			if l % 2 == 1:
				print(1)
				flg = 1
				break
		if flg == 0:
			print(2)


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, S):
	S = [int(d) for d in S]
	odd = []
	even = []
	for (i, x) in enumerate(S):
		if i % 2 == 0:
			odd.append(x)
		else:
			even.append(x)
	if len(odd) > len(even):
		if any((x % 2 == 1 for x in odd)):
			return 1
		return 2
	if any((x % 2 == 0 for x in even)):
		return 2
	return 1
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	S = input().decode().strip()
	ans = solve(N, S)
	print(ans)


from __future__ import division, print_function
import sys
sys.setrecursionlimit(10 ** 4)
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f

def primeFactors(n):
	a = []
	while n % 2 == 0:
		a.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			a.append(i)
			n = n // i
	if n > 2:
		a.append(n)
	return a

def main():
	t = inin()
	for _ in range(t):
		n = inin()
		a = sin()
		b = []
		x = n % 2
		for i in range(n):
			if i % 2 == x ^ 1:
				b.append(int(a[i]))
		if x == 1:
			ans = 2
			for i in b:
				if i % 2 == 1:
					ans = 1
		else:
			ans = 1
			for i in b:
				if i % 2 == 0:
					ans = 2
		print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'R'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'R'[0]:
		A.append(sign * numb)
	return A
main()


t = int(input())
for i in range(t):
	n = int(input())
	k = input()
	if n == 1:
		if int(k) % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		even = []
		odd = []
		if (n - 1) % 2 == 0:
			turnsa = (n - 1) // 2
			turnsb = turnsa
		else:
			turnsa = (n - 1) // 2 + 1
			turnsb = (n - 1) // 2
		for (j, k) in enumerate(k, start=1):
			if j % 2 == 0:
				even.append(int(k))
			else:
				odd.append(int(k))
		for j in range(turnsa):
			deleted = False
			for k in odd:
				if k % 2 == 0:
					odd.remove(k)
					deleted = True
					break
			if not deleted and odd:
				odd.pop(0)
		for j in range(turnsb):
			deleted = False
			for k in even:
				if k % 2 != 0:
					even.remove(k)
					deleted = True
					break
			if not deleted and even:
				even.pop(0)
		if not even:
			ans = odd[0]
		else:
			ans = even[0]
		if ans % 2 != 0:
			print(1)
		else:
			print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	if n % 2 == 1:
		ans = 2
		for i in range(n):
			if i % 2 == 0 and int(a[i]) % 2 == 1:
				ans = 1
				break
	else:
		ans = 1
		for i in range(n):
			if i % 2 == 1 and int(a[i]) % 2 == 0:
				ans = 2
				break
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = int(input())
	if n == 1:
		if a % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		k = []
		while a > 0:
			z = a % 10
			k.append(z)
			a = a // 10
		k.reverse()
		if n % 2 != 0:
			o = 0
			e = 0
			for i in range(0, n, 2):
				if k[i] % 2 == 0:
					e += 1
				else:
					o += 1
			if o > 0:
				print(1)
			elif o == 0:
				print(2)
		else:
			o = 0
			e = 0
			for i in range(1, n, 2):
				if k[i] % 2 == 0:
					e += 1
				else:
					o += 1
			if e > 0:
				print(2)
			elif e == 0:
				print(1)


import sys
t = int(sys.stdin.readline().strip())
for j in range(t):
	n = int(sys.stdin.readline().strip())
	line = list(map(int, sys.stdin.readline().strip()))
	if n % 2 == 1:
		win = 2
		for i in range(0, n, 2):
			if line[i] % 2 == 1:
				win = 1
				break
		print(win)
	else:
		win = 1
		for i in range(1, n, 2):
			if line[i] % 2 == 0:
				win = 2
		print(win)


q = int(input())
for _ in range(q):
	n = int(input())
	astring = input()
	if n % 2 != 0:
		ans = 2
		for i in astring[::2]:
			if int(i) % 2 != 0:
				ans = 1
				break
		print(ans)
	else:
		ans = 1
		for i in astring[1::2]:
			if int(i) % 2 == 0:
				ans = 2
				break
		print(ans)


for _ in range(int(input())):
	n = int(input())
	a = input()
	x = 0
	y = 0
	for i in range(n):
		if i % 2 == 0 and int(a[i]) % 2 == 1:
			x += 1
		elif i % 2 == 1 and int(a[i]) % 2 == 0:
			y += 1
	if n % 2 == 1:
		if x > 0:
			print(1)
		else:
			print(2)
	elif y > 0:
		print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	k = int(input())
	l = input()
	if k == 1:
		if int(l) % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		l = list(str(l))
		if k % 2 == 0:
			C = 1
			for i in range(1, k, 2):
				if int(l[i]) % 2 == 0:
					C = 2
					break
			print(C)
		else:
			K = 2
			for i in range(0, k, 2):
				if int(l[i]) % 2 != 0:
					K = 1
					break
			print(K)


t = int(input())
for ii in range(t):
	d = int(input())
	num = tuple(map(int, list(input())))
	try:
		if d % 2:
			if any((num[x] % 2 for x in range(0, d, 2))):
				print(1)
			else:
				print(2)
		elif any((num[x] % 2 == 0 for x in range(1, d, 2))):
			print(2)
		else:
			print(1)
	except IndexError:
		print(num)


for _ in range(int(input())):
	n = int(input())
	st = str(input())
	even = 0
	if len(st) == 1:
		if int(st[0]) % 2 == 0:
			print('2')
		else:
			print('1')
	else:
		evenONeven = False
		oddONodd = False
		for i in range(n):
			if (i + 1) % 2 == 0 and int(st[i]) % 2 == 0:
				evenONeven = True
			if (i + 1) % 2 != 0 and int(st[i]) % 2 != 0:
				oddONodd = True
		if n % 2 == 0:
			if evenONeven:
				print('2')
			else:
				print('1')
		elif oddONodd:
			print('1')
		else:
			print('2')


import os
import sys
from io import BytesIO, IOBase
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 RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	n = N()
	a = input()
	if n & 1:
		flag = True
		for i in range(0, n, 2):
			if int(a[i]) & 1:
				print(1)
				flag = False
				break
		if flag:
			print(2)
	else:
		flag = True
		for i in range(1, n, 2):
			if int(a[i]) & 1 == 0:
				print(2)
				flag = False
				break
		if flag:
			print(1)


for _ in range(int(input())):
	n = int(input())
	A = str(int(input()))
	if n % 2 == 0:
		for _ in range(1, n, 2):
			if int(A[_]) % 2 == 0:
				print(2)
				break
		else:
			print(1)
	else:
		for _ in range(0, n, 2):
			if int(A[_]) % 2 == 1:
				print(1)
				break
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	num = int(input())
	if n == 1:
		if num % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		flag = 0
		res = [int(x) for x in str(num)]
		if n % 2 == 0:
			for i in range(n):
				if i % 2 != 0:
					if res[i] % 2 == 0:
						flag = 1
						break
			if flag == 1:
				print(2)
			else:
				print(1)
		else:
			for i in range(n):
				if i % 2 == 0:
					if res[i] % 2 != 0:
						flag = 1
						break
			if flag == 1:
				print(1)
			else:
				print(2)


import sys

def solve(n, s):
	if n % 2 == 0:
		for h in range(n):
			if (h + 1) % 2 == 0:
				if int(s[h]) % 2 == 0:
					return '2'
		return '1'
	for p in range(n):
		if (p + 1) % 2 == 1:
			if int(s[p]) % 2 == 1:
				return '1'
	return '2'
t = int(sys.stdin.readline())
ans_arr = []
for i in range(t):
	n = int(sys.stdin.readline())
	s = sys.stdin.readline().strip()
	ans_arr.append(str(solve(n, s)))
print('\n'.join(ans_arr))


def digitsWinner(str_num, n):
	(odds, evens) = ([], [])
	(odds_evens, evens_odds) = ([], [])
	for i in range(1, n + 1):
		num = int(str_num[i - 1])
		odds.append(num) if i % 2 == 1 else evens.append(num)
		if i % 2 == 1 and num % 2 == 0:
			odds_evens.append(num)
		elif i % 2 == 0 and num % 2 == 1:
			evens_odds.append(num)
	for i in range(1, n):
		if i % 2 == 1:
			if len(odds_evens):
				odds.remove(odds_evens.pop())
			else:
				odds.pop()
		elif len(evens_odds):
			evens.remove(evens_odds.pop())
		else:
			evens.pop()
	last_digit = odds[0] if len(odds) > len(evens) else evens[0]
	ans = 1 if last_digit % 2 == 1 else 2
	print(ans)
t = int(input())
for _ in range(t):
	n = int(input())
	num = input()
	digitsWinner(num, n)


for _ in range(int(input())):
	n = int(input())
	Num = input()
	(Even, Odd) = (False, False)
	if n % 2 == 0:
		for i in range(n):
			if (i + 1) % 2 == 0 and int(Num[i]) % 2 == 0:
				Even = True
				break
		if Even:
			print(2)
		else:
			print(1)
	else:
		for i in range(n):
			if (i + 1) % 2 != 0 and int(Num[i]) % 2 != 0:
				Odd = True
				break
		if Odd:
			print(1)
		else:
			print(2)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	n = I()
	s = input().strip()
	if n % 2:
		f = 2
		for i in range(0, n, 2):
			if int(s[i]) % 2:
				f = 1
		print(f)
	else:
		f = 1
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				f = 2
		print(f)
for _ in range(I()):
	solve()


try:
	t = int(input())
	for i in range(t):
		n = int(input())
		s = input()
		l = list(s)
		l = [int(x) for x in l]
		(flag, flag2) = (0, 0)
		for i in range(0, n, 2):
			if l[i] % 2 != 0:
				flag = 1
				break
		for i in range(1, n, 2):
			if l[i] % 2 == 0:
				flag2 = 1
				break
		if n % 2 != 0:
			if flag == 1:
				print(1)
			else:
				print(2)
		elif flag2 == 1:
			print(2)
		else:
			print(1)
except:
	pass


import itertools
import math
import sys
from collections import defaultdict

def stdinWrapper():
	data = '4\n1\n2\n1\n3\n3\n102\n4\n2069\n\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield input()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def solve(a):
	a = [x for x in str(a)]
	if len(a) != 1:
		r = [x for (i, x) in enumerate(a) if i % 2 == 0]
		b = [x for (i, x) in enumerate(a) if i % 2 != 0]
		if len(a) % 2 == 0:
			return 2 if any([x for x in b if int(x) % 2 == 0]) else 1
		else:
			return 1 if any([x for x in r if int(x) % 2 == 1]) else 2
	return 1 if int(a[0]) % 2 == 1 else 2
t = getType(int)
for _ in range(t):
	n = getType(int)
	a = getType(int)
	res = solve(a)
	print(res)


from sys import stdin, stdout
import math
t = int(stdin.readline())
for _ in range(t):
	n = int(input())
	s = input()
	if len(s) % 2 == 1:
		winner = 2
		for i in range(0, len(s), 2):
			if int(s[i]) % 2 == 1:
				winner = 1
				break
		print(winner)
	else:
		winner = 1
		for i in range(1, len(s), 2):
			if int(s[i]) % 2 == 0:
				winner = 2
				break
		print(winner)


for _ in range(int(input())):
	n = int(input())
	s = input()
	l = list(s)
	breach = False
	raven = False
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(l[i]) % 2 == 0:
				breach = True
				print(2)
				break
		if not breach:
			print(1)
	else:
		for i in range(0, n, 2):
			if int(l[i]) % 2 != 0:
				raven = True
				print(1)
				break
		if not raven:
			print(2)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	b = []
	od = 0
	l1 = 0
	ev = 0
	l2 = 0
	for j in range(n):
		if j % 2 == 0:
			if int(s[j]) % 2 != 0:
				od += 1
		else:
			l2 += 1
			if int(s[j]) % 2 == 0:
				ev += 1
	f = 0
	if n == 1 and int(s) % 2 == 0:
		f = 1
	if n % 2 == 0:
		if ev != 0:
			f = 1
	elif od == 0:
		f = 1
	if f == 0:
		print(1)
	else:
		print(2)


for case in range(int(input())):
	n = int(input())
	s = input()
	even = 0
	odd = 0
	for c in s:
		if int(c) % 2 == 0:
			even += 1
		else:
			odd += 1
	if even == 0:
		print(1)
		continue
	elif odd == 0:
		print(2)
		continue
	if n % 2 == 0:
		even_at_even = False
		for i in range(n):
			if i % 2 == 1 and int(s[i]) % 2 == 0:
				even_at_even = True
				break
		if even_at_even:
			print(2)
		else:
			print(1)
	else:
		odd_at_odd = False
		for i in range(n):
			if i % 2 == 0 and int(s[i]) % 2 == 1:
				odd_at_odd = True
				break
		if odd_at_odd:
			print(1)
		else:
			print(2)


t = int(input())
while t:
	t -= 1
	n = int(input())
	num = int(input())
	f = 0
	if n % 2 == 1:
		for i in range(n):
			if f == 0 and (n - i) % 2 == 1 and (num % 10 % 2 == 1):
				f = 1
				break
			num //= 10
		if f == 1:
			print(1)
		else:
			print(2)
	else:
		for i in range(n):
			if f == 0 and (n - i) % 2 == 0 and (num % 10 % 2 == 0):
				f = 1
				break
			num //= 10
		if f == 1:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	x = ''
	if n % 2 == 0:
		z = 1
		for i in range(1, n, 2):
			x += s[i]
			f = int(x)
			if f % 2 == 0:
				z = 2
				break
			x = ''
	else:
		z = 2
		for i in range(0, n, 2):
			x += s[i]
			f = int(x)
			if f % 2 != 0:
				z = 1
				break
			x = ''
	print(z)


t = int(input())
result = []
res = 0
for i in range(t):
	n = int(input())
	x = [int(b) for b in str(int(input()))]
	odd = []
	even = []
	for j in range(n):
		if j % 2 == 0:
			odd.append(x[j])
		else:
			even.append(x[j])
	if n == 1:
		if x[0] % 2 == 0:
			res = 2
		else:
			res = 1
	elif n % 2 == 0:
		res = 1
		for a in even:
			if a % 2 == 0:
				res = 2
				break
	else:
		res = 2
		for a in odd:
			if a % 2 == 1:
				res = 1
				break
	result.append(res)
for i in range(t):
	print(result[i])


for t in range(int(input())):
	n = int(input())
	a = input()
	pair = False
	raze = False
	breach = False
	for c in a:
		k = int(c)
		if k % 2 == 1 and pair == False:
			raze = True
		if k % 2 == 0 and pair == True:
			breach = True
		pair = not pair
	if n % 2:
		print(1 if raze else 2)
	else:
		print(2 if breach else 1)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	k = 0
	if n % 2 == 0:
		for j in range(1, n, 2):
			if int(x[j]) % 2 == 0:
				k = k + 1
		if k > 0:
			print('2')
		else:
			print('1')
	else:
		for j in range(0, n, 2):
			if int(x[j]) % 2 != 0:
				k = k + 1
		if k > 0:
			print('1')
		else:
			print('2')


T = int(input())
for i in range(T):
	l = int(input())
	x = int(input())
	flag = 0
	if l % 2 == 0:
		while x > 0:
			c = x % 10
			if c % 2 == 0:
				flag = 2
				break
			else:
				flag = 1
			x = x // 100
	elif l == 1:
		if x % 2 == 0:
			flag = 2
		else:
			flag = 1
	else:
		while x > 0:
			c = x % 10
			if c % 2 == 1:
				flag = 1
				break
			else:
				flag = 2
			x = x // 100
	print(flag)


def solve():
	n = int(input())
	s = input()
	(oo, oe, eo, ee) = (0, 0, 0, 0)
	for i in range(n):
		if i % 2 == 0 and s[i] in '13579':
			oo += 1
		if i % 2 == 0 and s[i] in '02468':
			oe += 1
		if i % 2 == 1 and s[i] in '13579':
			eo += 1
		if i % 2 == 1 and s[i] in '02468':
			ee += 1
	if n % 2 == 0:
		print(2 if ee > 0 else 1)
	if n % 2 == 1:
		print(1 if oo > 0 else 2)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	value = input()
	raich = 0
	brich = 0
	for i in range(n):
		if (i + 1) % 2:
			raich += int(value[i]) % 2
		else:
			brich += (int(value[i]) + 1) % 2
	if n % 2:
		if raich:
			print(1)
		else:
			print(2)
	elif brich:
		print(2)
	else:
		print(1)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = list(map(int, list(input())))
	(x, y, i) = (0, 0, 1)
	if n == 1:
		if s[0] % 2 == 1:
			print(1)
		else:
			print(2)
		continue
	while i < n:
		if s[i - 1] % 2 == 1:
			x = 1
		if s[i] % 2 == 0:
			y = 1
		i += 2
	if n % 2 == 1:
		if x == 1:
			print(1)
		else:
			print(2)
	elif y == 1:
		print(2)
	else:
		print(1)


import sys, os.path
from collections import *
from copy import *
import math
mod = 10 ** 9 + 7
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	n = int(input())
	a = int(input())
	s = str(a)
	odd = 0
	even = 0
	if n == 1:
		if a % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		for i in range(n):
			if i % 2 == 1 and int(s[i]) % 2 == 1:
				odd += 1
		if odd == n // 2:
			print(1)
		else:
			print(2)
	else:
		for i in range(n):
			if i % 2 == 0 and int(s[i]) % 2 == 0:
				even += 1
		if even == n // 2 + 1:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	num = input()
	found = False
	if not len(num) % 2:
		for i in num[1:len(num):2]:
			if int(i) % 2 == 0:
				found = True
				print(2)
				break
		if not found:
			print(1)
	else:
		for i in num[0:len(num):2]:
			if int(i) % 2:
				found = True
				print(1)
				break
		if not found:
			print(2)


import collections
for t in range(int(input())):
	n = int(input())
	s = input()
	o1 = o2 = e1 = e2 = 0
	for i in range(n):
		if i % 2 == 1:
			if int(s[i]) % 2 == 1:
				o2 += 1
			else:
				e2 += 1
		elif int(s[i]) % 2 == 1:
			o1 += 1
		else:
			e1 += 1
	if n % 2 == 0:
		if e2 > 0:
			print(2)
		else:
			print(1)
	else:
		v = n // 2
		if o1 != 0:
			o1 = o1 + e1 - v
		if e2 != 0:
			e2 = o2 + e2 - v
		if o1 > 0:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	s = str(input())
	if n % 2 == 0:
		flag = False
		flagg = False
		for i in range(n):
			if i + 1 & 1:
				if int(s[i]) % 2 != 0:
					flag = True
			elif int(s[i]) % 2 == 0:
				flagg = True
		if flagg:
			print(2)
		else:
			print(1)
	else:
		flag = False
		flagg = False
		for i in range(n):
			if i + 1 & 1:
				if int(s[i]) % 2 != 0:
					flag = True
			elif int(s[i]) % 2 == 0:
				flagg = True
		if flag:
			print(1)
		else:
			print(2)


import math

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

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	n = int(input())
	s = input()
	if n == 1:
		if int(s[0]) % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	f = 0
	if n % 2 == 1:
		for i in range(len(s)):
			if (i + 1) % 2 == 1:
				if int(s[i]) % 2 == 1:
					f = 1
		if f == 1:
			print(1)
		else:
			print(2)
	if n % 2 == 0:
		for i in range(len(s)):
			if (i + 1) % 2 == 0:
				if int(s[i]) % 2 == 0:
					f = 1
		if f == 1:
			print(2)
		else:
			print(1)


import math
from heapq import heappush, heappop, heapify
import random
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	n = I()
	s = S()
	if n % 2 == 0:
		ans = 1
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				ans = 2
				break
		print(ans)
	else:
		ans = 2
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 1:
				ans = 1
				break
		print(ans)


import sys
input = sys.stdin.readline
n = int(input())
for ii in range(n):
	n = int(input())
	a = [int(i) for i in input() if i != '\n']
	(raze, breach) = (False, False)
	for i in range(len(a)):
		if i + 1 & 1 and a[i] & 1:
			raze = True
		elif (i + 1) % 2 == 0 and a[i] % 2 == 0:
			breach = True
	if n & 1:
		if raze:
			print(1)
		else:
			print(2)
	elif breach:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	x = int(input())
	if n == 1:
		if x % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	if n % 2 == 0:
		f = 0
		cnt = 0
		while x != 0:
			s = x % 10
			x = x // 10
			if cnt % 2 == 0 and s % 2 == 0:
				f = 1
				break
			cnt += 1
		if f:
			print(2)
		else:
			print(1)
	else:
		f = 0
		cnt = 1
		while x != 0:
			s = x % 10
			x = x // 10
			if cnt % 2 == 1 and s % 2 == 1:
				f = 1
				break
			cnt += 1
		if f:
			print(1)
		else:
			print(2)


import sys as _sys

def main():
	t = int(input())
	for i_t in range(t):
		(n,) = _read_ints()
		assert n >= 1
		x_digits = tuple(map(int, _read_line()))
		even_position_remain = n % 2 == 0
		if even_position_remain:
			even_wins = any((digit % 2 == 0 for digit in x_digits[1::2]))
		else:
			even_wins = all((digit % 2 == 0 for digit in x_digits[0::2]))
		result = 2 if even_wins else 1
		print(result)

def _read_line():
	result = _sys.stdin.readline()
	assert result[-1] == '\n'
	return result[:-1]

def _read_ints():
	return map(int, _read_line().split(' '))
main()


t = int(input())
for zzz in range(t):
	raze = False
	breach = False
	n = int(input())
	num = input()
	if n % 2 == 0:
		for i in range(1, n, 2):
			if int(num[i]) % 2 == 0:
				breach = True
		if breach:
			print(2)
		else:
			print(1)
	else:
		for i in range(0, n, 2):
			if int(num[i]) % 2 == 1:
				raze = True
		if raze:
			print(1)
		else:
			print(2)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p), end=': ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	s = list(inp())
	for i in range(n):
		s[i] = int(s[i])
	if n % 2 == 0:
		odd = 0
		even = 0
		for i in range(1, n, 2):
			if s[i] % 2 == 0:
				even += 1
			else:
				odd += 1
		if even > 0:
			print(2)
		else:
			print(1)
	else:
		odd = 0
		even = 0
		for i in range(0, n, 2):
			if s[i] % 2 == 0:
				even += 1
			else:
				odd += 1
		if odd > 0:
			print(1)
		else:
			print(2)
testcase(int(inp()))


t = int(input())
for i in range(t):
	n = int(input())
	digits = list(str(input()))
	flag = False
	if n % 2 == 0:
		for t in range(1, n, 2):
			if int(digits[t]) % 2 == 0:
				flag = True
				break
			flag = False
	else:
		for t in range(0, n, 2):
			if int(digits[t]) % 2:
				flag = False
				break
			flag = True
	if flag:
		print(2)
	else:
		print(1)


for _ in range(0, int(input())):
	n = int(input())
	v = input()
	a = all((int(i) % 2 == 0 for i in v[::2]))
	b = all((int(i) % 2 == 1 for i in v[1::2]))
	f = [2 - b, 1 + a]
	print(f[n % 2])


import sys

def multiple_input():
	return map(int, sys.stdin.readline().strip().split())

def list_input():
	return list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	n = int(input())
	s = input()
	flag = 0
	if n % 2 != 0:
		for i in range(0, len(s), 2):
			if int(s[i]) % 2 != 0:
				flag = 1
		if flag == 0:
			flag = 2
	else:
		for i in range(1, len(s), 2):
			if int(s[i]) % 2 == 0:
				flag = 2
				break
		if flag == 0:
			flag = 1
	print(flag)


t = int(input())
for i in range(t):
	n = int(input())
	num = int(input())
	s = str(num)
	flag = 0
	flag1 = 0
	if len(s) % 2 == 0:
		for j in range(1, n, 2):
			if int(s[j]) % 2 == 0:
				print(2)
				flag = 1
				break
		if flag == 0:
			print(1)
	else:
		for j in range(0, n, 2):
			if int(s[j]) % 2 != 0:
				print(1)
				flag1 = 1
				break
		if flag1 == 0:
			print(2)


for t in range(int(input())):
	n = int(input())
	s = input()
	(re, ro) = ([], [])
	(be, bo) = ([], [])
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2 == 0:
				re.append(int(s[i]))
			else:
				ro.append(int(s[i]))
		elif int(s[i]) % 2 == 0:
			be.append(int(s[i]))
		else:
			bo.append(int(s[i]))
	r = ro + re
	b = be + bo
	cnt = 0
	while n - cnt > 1:
		if cnt % 2 == 0:
			r.pop()
			cnt += 1
		else:
			b.pop()
			cnt += 1
	rb = r + b
	if rb[0] % 2:
		print(1)
	else:
		print(2)


T = int(input())
ans = [1] * T
for t in range(T):
	N = int(input())
	S = list(map(int, list(input())))
	if N % 2 == 0:
		for i in range(1, N, 2):
			if S[i] % 2 == 0:
				ans[t] = 2
				break
	else:
		for i in range(0, N, 2):
			if S[i] % 2 == 1:
				break
		else:
			ans[t] = 2
print(*ans, sep='\n')


def solve():
	n = int(input())
	s = input()
	if n == 1:
		if int(s[0]) % 2 == 0:
			return 2
		else:
			return 1
	oo = 0
	oe = 0
	eo = 0
	ee = 0
	for i in range(n):
		if i % 2 != 0:
			if int(s[i]) % 2 == 0:
				ee += 1
			else:
				eo += 1
		elif int(s[i]) % 2 == 0:
			oe += 1
		else:
			oo += 1
	if n % 2 != 0:
		if oo >= 1:
			return 1
		else:
			return 2
	elif ee >= 1:
		return 2
	else:
		return 1
for _ in range(int(input())):
	print(solve())


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input()))
	odd = []
	eve = []
	rodd = []
	reve = []
	bodd = []
	beve = []
	for i in range(n):
		if (i + 1) % 2 == 0:
			eve.append(arr[i])
		else:
			odd.append(arr[i])
	for i in odd:
		if i % 2 == 0:
			reve.append(i)
		else:
			rodd.append(i)
	for i in eve:
		if i % 2 == 0:
			beve.append(i)
		else:
			bodd.append(i)
	while len(arr) > 1:
		if len(reve) != 0:
			a = reve.pop()
		else:
			a = rodd.pop()
		arr.remove(a)
		if len(arr) == 1:
			break
		if len(bodd) != 0:
			b = bodd.pop()
		else:
			b = beve.pop()
		arr.remove(b)
	if arr[0] % 2 == 0:
		print(2)
	else:
		print(1)


import sys
LI = lambda : list(map(int, sys.stdin.readline().strip('\n').split()))
MI = lambda : map(int, sys.stdin.readline().strip('\n').split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline().strip('\n'))
for _ in range(II()):
	n = II()
	s = SI()
	win = 2
	if n % 2:
		odd = False
		for (i, c) in enumerate(s, 1):
			if i % 2 and int(c) % 2:
				odd = True
		if odd:
			win = 1
	else:
		evn = False
		for (i, c) in enumerate(s, 1):
			if not i % 2 and (not int(c) % 2):
				evn = True
		if not evn:
			win = 1
	print(win)


def main():
	for _ in range(int(input())):
		digits = int(input())
		num = int(input())
		if digits & 1:
			flag = 0
			while num != 0:
				if num % 10 & 1:
					flag = 1
					break
				num //= 10
				num //= 10
			if flag == 1:
				print(1)
			else:
				print(2)
		else:
			flag = 0
			while num != 0:
				if not num % 10 & 1:
					flag = 1
					break
				num //= 10
				num //= 10
			if flag == 1:
				print(2)
			else:
				print(1)
main()


import math as ma
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	d = ma.floor(ma.log10(int(s))) + 1
	if n == 1:
		if int(s[0]) % 2 == 0:
			print(2)
			continue
		else:
			print(1)
			continue
	if d % 2 != 0:
		for i in range(0, n, 2):
			if int(s[i]) % 2 != 0:
				print(1)
				break
			elif i == n - 1:
				print(2)
				break
	else:
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				print(2)
				break
			elif i == n - 1:
				print(1)
				break


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	a = [int(a[i]) for i in range(n)]
	c = []
	d = []
	for i in range(n):
		if i % 2 == 0:
			c.append(a[i])
		else:
			d.append(a[i])
	if n % 2 == 0:
		f = 0
		for i in range(len(d)):
			if d[i] % 2 == 0:
				f = 1
				break
		if f == 1:
			print(2)
		else:
			print(1)
	else:
		f = 0
		for i in range(len(c)):
			if c[i] % 2 != 0:
				f = 1
				break
		if f == 1:
			print(1)
		else:
			print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	(rodd, beven) = (0, 0)
	for t in range(n):
		if int(a[t]) % 2 != 0 and (t + 1) % 2 != 0:
			rodd += 1
		elif int(a[t]) % 2 == 0 and (t + 1) % 2 == 0:
			beven += 1
	if rodd >= 1 and n % 2 != 0:
		print(1)
	elif rodd == 0 and n % 2 != 0:
		print(2)
	elif beven >= 1 and n % 2 == 0:
		print(2)
	elif beven == 0 and n % 2 == 0:
		print(1)


t = int(input())
for p in range(t):
	a = int(input())
	n = int(input())
	s = str(n)
	if a % 2 == 0:
		i = 1
		flag1 = False
		while i < len(s):
			if int(s[i]) % 2 == 0:
				flag1 = True
			i += 2
		if flag1:
			print(2)
		else:
			print(1)
	else:
		i = 0
		flag2 = False
		while i < len(s):
			if int(s[i]) % 2 != 0:
				flag2 = True
			i += 2
		if flag2:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	s = input()
	raze = [int(s[i]) % 2 for i in range(0, n, 2)]
	beach = [int(s[i]) % 2 for i in range(1, n, 2)]
	if n % 2 == 0:
		print(2 if 0 in beach else 1)
	else:
		print(1 if 1 in raze else 2)


import sys
sys.setrecursionlimit(10 ** 7)

def I():
	return int(sys.stdin.readline().rstrip())

def MI():
	return map(int, sys.stdin.readline().rstrip().split())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def LI2():
	return list(map(int, sys.stdin.readline().rstrip()))

def S():
	return sys.stdin.readline().rstrip()

def LS():
	return list(sys.stdin.readline().rstrip().split())

def LS2():
	return list(sys.stdin.readline().rstrip())
t = I()
for _ in range(t):
	n = I()
	S = LI2()
	R = S[::2]
	B = S[1::2]
	if n % 2 == 0:
		for b in B:
			if b % 2 == 0:
				print(2)
				break
		else:
			print(1)
	else:
		for r in R:
			if r % 2 == 1:
				print(1)
				break
		else:
			print(2)


from collections import *
t = int(input())
while t:
	t -= 1
	n = int(input())
	game = [int(x) for x in list(input())]
	rais = deque()
	breach = deque()
	for i in range(n):
		if i % 2 == 0:
			if game[i] % 2:
				rais.append(game[i])
			else:
				rais.appendleft(game[i])
		elif game[i] % 2:
			breach.appendleft(game[i])
		else:
			breach.append(game[i])
	if n % 2:
		x = rais.pop()
	else:
		x = breach.pop()
	if x % 2:
		print(1)
	else:
		print(2)


t = int(input())
for case in range(t):
	n = int(input())
	s = input()
	if n % 2 == 1:
		if sum([int(x) % 2 for x in s[::2]]) > 0:
			print(1)
		else:
			print(2)
	elif sum([(int(x) + 1) % 2 for x in s[1::2]]) > 0:
		print(2)
	else:
		print(1)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	x = input()
	arr = []
	for i in range(n):
		arr.append(int(x[i]))
	breach = arr[1::2]
	raze = arr[::2]
	(bodd, beven, rodd, reven) = (0, 0, 0, 0)
	for item in breach:
		if item % 2 == 0:
			beven += 1
		else:
			bodd += 1
	for item in raze:
		if item % 2 == 0:
			reven += 1
		else:
			rodd += 1
	for i in range((n - 1) // 2):
		if bodd > 0:
			bodd -= 1
		else:
			beven -= 1
		if reven > 0:
			reven -= 1
		else:
			rodd -= 1
	if n % 2 == 0:
		if reven > 0:
			reven -= 1
		else:
			rodd -= 1
	if beven + reven == 1:
		print(2)
	else:
		print(1)


t = int(input())
while t:
	n = int(input())
	a = list(input())
	a = list(map(int, a))
	flag = 1
	if n % 2:
		flag = 0
		for x in range(0, n, 2):
			if a[x] % 2:
				flag = 1
				break
	else:
		for x in range(1, n, 2):
			if a[x] % 2 == 0:
				flag = 0
				break
	if flag:
		print(1)
	else:
		print(2)
	t -= 1


for i in range(int(input())):
	n = int(input())
	x = input()
	r = []
	b = []
	for i in range(len(x)):
		if i & 1:
			if int(x[i]) % 2:
				b.append(int(x[i]))
			else:
				b.insert(0, int(x[i]))
		elif int(x[i]) % 2 == 0:
			r.append(int(x[i]))
		else:
			r.insert(0, int(x[i]))
	f = 1
	for i in range(n - 1):
		if f:
			if len(r) != 0:
				r.pop()
		elif len(b) != 0:
			b.pop()
		f = (f + 1) % 2
	if len(r) == 1:
		if r[0] % 2:
			print(1)
		else:
			print(2)
	elif b[0] % 2:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	n = int(input())
	t = input()
	Breach = []
	Raze = []
	B = False
	R = False
	for (i, s) in enumerate(t):
		if i % 2:
			Breach.append(int(s))
			if int(s) % 2 == 0:
				B = True
		else:
			Raze.append(int(s))
			if int(s) % 2 == 1:
				R = True
	if n % 2 == 1:
		if R:
			print(1)
		else:
			print(2)
	elif B:
		print(2)
	else:
		print(1)


import sys
input = sys.stdin.readline
t = int(input())
for x in range(t):
	n = int(input())
	D = list(map(int, input().strip()))
	odd_on_odd_position = False
	even_on_even_position = False
	for (pos, d) in enumerate(D, 1):
		if pos % 2 == 1 and d % 2 == 1:
			odd_on_odd_position = True
		if pos % 2 == 0 and d % 2 == 0:
			even_on_even_position = True
	if n % 2 == 1:
		print(1 if odd_on_odd_position else 2)
	else:
		print(2 if even_on_even_position else 1)


def get_raze_stack(num):
	evens = []
	odds = []
	for i in range(len(num)):
		if i % 2 != 0:
			continue
		if int(num[i]) % 2 == 0:
			evens.append(int(num[i]))
		else:
			odds.append(int(num[i]))
	return odds + evens

def get_breach_stack(num):
	evens = []
	odds = []
	for i in range(len(num)):
		if i % 2 == 0:
			continue
		if int(num[i]) % 2 == 0:
			evens.append(int(num[i]))
		else:
			odds.append(int(num[i]))
	return evens + odds

def solve():
	n = int(input())
	num = list(input())
	if len(num) == 1:
		return 1 if int(num[0]) % 2 != 0 else 2
	stack = []
	if len(num) % 2 == 0:
		stack = get_breach_stack(num)
	else:
		stack = get_raze_stack(num)
	return 1 if stack[0] % 2 != 0 else 2
matches = int(input())
for i in range(matches):
	print(solve())


for _ in range(int(input())):
	n = int(input())
	s = input()
	even = 0
	odd = 0
	for i in range(1, n + 1, 2):
		if int(s[i - 1]) % 2 == 0:
			even += 1
		else:
			odd += 1
	eve = 0
	od = 0
	for i in range(2, n + 1, 2):
		if int(s[i - 1]) % 2 == 0:
			eve += 1
		else:
			od += 1
	if n % 2 == 0:
		if eve >= 1:
			print(2)
		else:
			print(1)
	elif odd >= 1:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	digits = list(map(int, list(input())))
	if n % 2 == 1:
		containsOdd = False
		for i in range(0, n, 2):
			if digits[i] % 2 == 1:
				containsOdd = True
		if containsOdd:
			print(1)
		else:
			print(2)
	else:
		containsEven = False
		for i in range(1, n, 2):
			if digits[i] % 2 == 0:
				containsEven = True
		if containsEven:
			print(2)
		else:
			print(1)


for run in range(int(input())):
	m = int(input())
	n = input()
	for i in range(1 - m % 2, m, 2):
		x = 1 + m % 2
		if int(n[i]) % 2 == m % 2:
			x += 1
			break
	if x == 2:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	if n == 1:
		if int(a[0]) % 2 == 0:
			print('2')
		else:
			print('1')
	else:
		cn = 0
		if n % 2 == 0:
			for i in range(1, n, 2):
				if int(a[i]) % 2 == 0:
					cn = 1
					break
			if cn == 1:
				print('2')
			else:
				print('1')
		else:
			for i in range(0, n, 2):
				if int(a[i]) % 2 != 0:
					cn = 1
					break
			if cn == 1:
				print('1')
			else:
				print('2')


for _ in range(int(input())):
	n = int(input())
	num = [int(i) for i in input()]
	if n == 1:
		if num[0] % 2 == 0:
			print(2)
			continue
		else:
			print(1)
			continue
	if n % 2 == 0:
		for i in num[1::2]:
			if i % 2 == 0:
				print(2)
				break
		else:
			print(1)
	else:
		for i in num[0::2]:
			if i % 2 != 0:
				print(1)
				break
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	num = input()
	f = 0
	if n % 2 == 0:
		c = 0
		for i in num:
			c += 1
			if int(i) % 2 == 0 and c % 2 == 0:
				print(2)
				f = 1
				break
		if f == 0:
			print(1)
	else:
		c = 0
		f = 0
		for i in num:
			c += 1
			if int(i) % 2 == 1 and c % 2 == 1:
				print(1)
				f = 1
				break
		if f == 0:
			print(2)


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve(N, num):
	if N % 2 == 0:
		for i in range(1, N, 2):
			if int(num[i]) % 2 == 0:
				return 2
		return 1
	else:
		for i in range(0, N, 2):
			if int(num[i]) % 2 == 1:
				return 1
		return 2
TC = int(input())
for tc in range(TC):
	N = int(input())
	num = input()
	res = solve(N, num)
	print(res)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac
from itertools import permutations as permu

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
num = int(z())
for _ in range(num):
	n = int(z())
	s = z()
	if n % 2:
		for i in s[::2]:
			if i in '13579':
				print(1)
				break
		else:
			print(2)
	else:
		for i in s[1::2]:
			if i in '24680':
				print(2)
				break
		else:
			print(1)


x = int(input())
for i in range(x):
	a = int(input())
	s = input()
	c = 0
	d = 0
	for i in range(a):
		if i % 2 != 0 and int(s[i]) % 2 == 0:
			c += 1
		elif i % 2 == 0 and int(s[i]) % 2 != 0:
			d += 1
	if c > 0 and a % 2 == 0:
		print(2)
	elif c == 0 and a % 2 == 0:
		print(1)
	if d > 0 and a % 2 != 0:
		print(1)
	elif d == 0 and a % 2 != 0:
		print(2)


N = int(input())
Ans = []
for i in range(N):
	k = int(input())
	T = list(input())
	r_k = 0
	r_g = 0
	b_k = 0
	b_g = 0
	for j in range(len(T)):
		if (j + 1) % 2 == 1:
			if int(T[j]) % 2 == 1:
				r_k += 1
			else:
				r_g += 1
		elif int(T[j]) % 2 == 1:
			b_k += 1
		else:
			b_g += 1
	if len(T) % 2 == 0:
		if b_g == 0:
			Ans.append(1)
		else:
			Ans.append(2)
	elif r_k == 0:
		Ans.append(2)
	else:
		Ans.append(1)
for i in Ans:
	print(i)


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	a = [int(x) for x in a]
	if len(a) % 2 != 0:
		b = [i % 2 for i in a]
		(c, d) = ([], [])
		for i in range(len(b)):
			if i % 2 == 0:
				c.append(b[i])
			else:
				d.append(b[i])
		if c.count(1) == 0:
			print(2)
		else:
			print(1)
	else:
		b = [i % 2 for i in a]
		(c, d) = ([], [])
		for i in range(len(b)):
			if i % 2 == 0:
				c.append(b[i])
			else:
				d.append(b[i])
		if d.count(0) == 0:
			print(1)
		else:
			print(2)


import sys
for _ in range(int(input())):
	n = int(sys.stdin.readline())
	arr = list(map(str, sys.stdin.readline().rstrip()))
	for i in range(n):
		arr[i] = int(arr[i])
	flag = 0
	if n % 2 == 0:
		for i in range(1, n, 2):
			if arr[i] % 2 == 0:
				print('2')
				flag = 1
				break
		if flag == 0:
			print('1')
	elif n % 2 == 1:
		for i in range(0, n, 2):
			if arr[i] % 2 == 1:
				print('1')
				flag = 1
				break
		if flag == 0:
			print('2')


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = [int(s[i]) for i in range(0, n, 2)]
	b = [int(s[i]) for i in range(1, n, 2)]
	if n % 2 == 0:
		if any((i % 2 == 0 for i in b)):
			print(2)
		else:
			print(1)
	elif any((i % 2 == 1 for i in a)):
		print(1)
	else:
		print(2)


t = int(input())
for j in range(t):
	n = int(input())
	d = int(input())
	if n % 2 == 1:
		c = 0
		s = str(d)
		for i in range(0, len(s), 2):
			digit = int(s[i])
			if digit % 2 == 1:
				c = 1
				break
		if c == 1:
			print(1)
		else:
			print(2)
	else:
		c = 0
		s = str(d)
		for i in range(1, len(s), 2):
			digit = int(s[i])
			if digit % 2 == 0:
				c = 1
				break
		if c == 1:
			print(2)
		else:
			print(1)


from collections import deque
n = int(input())
for i in range(n):
	a = int(input())
	b = int(input())
	f = b
	l = []
	while f:
		e = f % 10
		l.append(e)
		f = f // 10
	l.reverse()
	visit = [0] * a
	d1 = deque()
	d2 = deque()
	for i in range(a):
		if i % 2 == 0:
			if l[i] % 2 == 0:
				d1.append(i)
			else:
				d1.appendleft(i)
		if i % 2 != 0:
			if l[i] % 2 != 0:
				d2.append(i)
			else:
				d2.appendleft(i)
	j = 0
	while j < a - 1:
		if j % 2 == 0:
			w = d1.pop()
			visit[w] = 1
		if j % 2 != 0:
			w = d2.pop()
			visit[w] = 1
		j = j + 1
	for i in range(a):
		if visit[i] == 0:
			break
	if l[i] % 2 == 0:
		print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, list(input())))
	raze = arr[::2]
	bre = arr[1::2]
	winner = None
	if n % 2 == 0:
		winner = 1
		for i in bre:
			if i % 2 == 0:
				winner = 2
				break
	else:
		winner = 2
		for i in raze:
			if i % 2 == 1:
				winner = 1
				break
	print(winner)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
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')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 30, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	n = int(input())
	s = input()
	c = 0
	c1 = 0
	for i in range(0, n, 2):
		if int(s[i]) % 2 == 1:
			c += 1
	for i in range(1, n, 2):
		if int(s[i]) % 2 == 0:
			c1 += 1
	if n % 2 == 1:
		if c > 0:
			print(1)
		else:
			print(2)
	if n % 2 == 0:
		if c1 > 0:
			print(2)
		else:
			print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	if n % 2 == 0:
		g = False
		i = 1
		while i < n:
			if int(a[i]) % 2 == 0:
				g = True
				break
			i = i + 2
		if g == True:
			print(2)
		else:
			print(1)
	else:
		g = False
		i = 0
		while i < n:
			if int(a[i]) % 2 == 1:
				g = True
				break
			i = i + 2
		if g == True:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	d = int(input())
	n = input()
	f = 2
	if d & 1:
		t = 0
		for i in range(d):
			if i + 1 & 1:
				num = ord(n[i]) - ord('0')
				if num & 1:
					t = 1
		if t:
			f = 1
	else:
		t = 1
		for i in range(d):
			if i & 1:
				num = ord(n[i]) - ord('0')
				if num & 1 != 1:
					t = 0
		if t:
			f = 1
	print(f)


from collections import defaultdict
from queue import deque

def arrinp():
	return [*map(int, input().split(' '))]

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

def intinp():
	return int(input())

def solution():
	n = intinp()
	s = input()
	if n % 2 == 0:
		win = 1
		for i in range(n):
			if i % 2 == 1:
				if int(s[i]) % 2 == 0:
					win = 2
	else:
		win = 2
		for i in range(n):
			if i % 2 == 0:
				if int(s[i]) % 2 == 1:
					win = 1
	print(win)
	return
testcases = 1
testcases = int(input())
for _ in range(testcases):
	solution()


q = []
t = int(input())
for i in range(t):
	n = int(input())
	s = int(input())
	m = s
	odd_at_odd = 0
	even_at_even = 0
	odd_at_even = 0
	even_at_odd = 0
	if n % 2 == 0:
		while m > 0:
			if m % 10 % 2 == 0:
				even_at_even += 1
			else:
				odd_at_even += 1
			m = m // 10
			if m % 10 % 2 == 0:
				even_at_odd += 1
			else:
				odd_at_odd += 1
			m = m // 10
	else:
		while m > 0:
			if m % 10 % 2 == 0:
				even_at_odd += 1
			else:
				odd_at_odd += 1
			m = m // 10
			if m % 10 % 2 == 0:
				even_at_even += 1
			else:
				odd_at_even += 1
			m = m // 10
	if n % 2 != 0:
		if odd_at_odd >= 1:
			q.append(1)
		else:
			q.append(2)
	elif even_at_even >= 1:
		q.append(2)
	else:
		q.append(1)
for i in q:
	print(i)


t = int(input())
for _ in range(t):
	n = int(input())
	num = input()
	res = 2
	if n % 2:
		for ch in num[::2]:
			if int(ch) % 2:
				res = 1
	else:
		res = 1
		for ch in num[1::2]:
			if int(ch) % 2 == 0:
				res = 2
	print(res)


t = int(input())
for aaa in range(t):
	cnt = int(input())
	s = input()
	odd = 0
	even = 0
	for i in range(cnt):
		ch = s[i]
		if (i + 1) % 2 == 0 and int(ch) % 2 == 0:
			even += 1
		if (i + 1) % 2 == 1 and int(ch) % 2 == 1:
			odd += 1
	if cnt % 2 == 0:
		if even > 0:
			print(2)
		else:
			print(1)
	if cnt % 2 == 1:
		if odd > 0:
			print(1)
		else:
			print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	d = input()
	l = [int(x) for x in d]
	if n & 1 == 1:
		f = 0
		for i in range(0, n, 2):
			if l[i] & 1 == 1:
				f = 1
				break
		if f == 1:
			print(1)
		else:
			print(2)
	else:
		f = 0
		for i in range(1, n, 2):
			if l[i] & 1 == 0:
				f = 1
				break
		if f == 1:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	r = []
	b = []
	rm = []
	bm = []
	n = int(input())
	s = input()
	j = 0
	ro = 0
	re = 0
	bo = 0
	be = 0
	for i in s:
		if j % 2 == 0:
			r.append(int(i))
			rm.append(0)
			if int(i) % 2 == 0:
				re += 1
			else:
				ro += 1
		else:
			b.append(int(i))
			bm.append(0)
			if int(i) % 2 == 0:
				be += 1
			else:
				bo += 1
		j += 1
	if n % 2 == 1:
		if ro > 0:
			print(1)
		else:
			print(2)
	elif be > 0:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	ln = int(input())
	n = input()
	if len(n) % 2 == 0:
		even = 0
		for i in range(ln):
			if i % 2 == 1:
				if int(n[i]) % 2 == 0:
					even += 1
		if even:
			print(2)
		else:
			print(1)
	else:
		odd = 0
		for i in range(ln):
			if i % 2 == 0:
				if int(n[i]) % 2 == 1:
					odd += 1
		if odd:
			print(1)
		else:
			print(2)


from collections import Counter, OrderedDict
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n,) = gil()
	a = gbs()
	(oo, oe, eo, ee) = (0, 0, 0, 0)
	for i in range(n):
		if i & 1 ^ 1:
			if a[i] & 1:
				oo += 1
			else:
				eo += 1
		elif a[i] & 1:
			oe += 1
		else:
			ee += 1
	if n & 1:
		if oo:
			print(1)
		else:
			print(2)
	elif ee:
		print(2)
	else:
		print(1)


t = int(input().strip())
for a0 in range(t):
	n = int(input())
	l = input()
	l = list(l)
	a = 1
	odd = []
	eve = []
	for i in l:
		if a % 2 != 0:
			odd.append(int(i))
		else:
			eve.append(int(i))
		a += 1
	if len(odd) > len(eve):
		flg = 0
		for i in odd:
			if i % 2 != 0:
				flg = 1
				break
		if flg == 1:
			print(1)
		else:
			print(2)
	else:
		flg = 0
		for i in eve:
			if i % 2 == 0:
				flg = 1
				break
		if flg == 1:
			print(2)
		else:
			print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	a = 0
	b = 0
	if n % 2 != 0:
		for i in range(n):
			if i % 2 == 0:
				if int(s[i]) % 2 != 0:
					print(1)
					break
		else:
			print(2)
	else:
		for i in range(n):
			if i % 2 != 0:
				if int(s[i]) % 2 == 0:
					print(2)
					break
		else:
			print(1)


for _ in range(int(input())):
	d = int(input())
	n = int(input())
	s = str(n)
	(oo, oe, eo, ee) = (0, 0, 0, 0)
	for i in range(d):
		if i % 2 == 0 and int(s[i]) % 2 == 1:
			eo += 1
		elif i % 2 == 1 and int(s[i]) % 2 == 0:
			oe += 1
	if d % 2 == 0:
		if oe > 0:
			r = 2
		else:
			r = 1
	elif eo > 0:
		r = 1
	else:
		r = 2
	print(r)


t = int(input())
for i in range(t):
	n = int(input())
	x = int(input())
	digits = []
	while x != 0:
		digits.insert(0, x % 10)
		x //= 10
	while len(digits) != n:
		digits.insert(0, 0)
	raze = digits[::2]
	breach = digits[1::2]
	if n % 2 == 0:
		if all((k % 2 == 1 for k in breach)):
			print(1)
		else:
			print(2)
	elif all((k % 2 == 0 for k in raze)):
		print(2)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	if n % 2:
		flag = 0
		for j in range(0, n, 2):
			if int(s[j]) % 2:
				flag = 1
		if flag:
			print(1)
		else:
			print(2)
	else:
		flag = 0
		for j in range(1, n, 2):
			if int(s[j]) % 2 == 0:
				flag = 1
		if flag:
			print(2)
		else:
			print(1)


t = int(input())

def digit(n, num):
	arr = []
	while num > 0:
		arr.append(num % 10)
		num = num // 10
	arr.reverse()
	if n % 2 == 1:
		for i in range(n):
			if i % 2 == 0 and arr[i] % 2 == 1:
				return 1
		return 2
	else:
		for i in range(n):
			if i % 2 == 1 and arr[i] % 2 == 0:
				return 2
		return 1
for i in range(t):
	n = int(input())
	num = int(input())
	print(digit(n, num))


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
for __ in range(int(input())):
	n = int(input())
	s = input()
	a = [0, 0]
	b = [0, 0]
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2 == 1:
				a[1] += 1
			else:
				a[0] += 1
		elif int(s[i]) % 2 == 1:
			b[1] += 1
		else:
			b[0] += 1
	if a[0] + b[0] == n:
		print(2)
	elif a[1] + b[1] == n:
		print(1)
	elif n % 2 == 1:
		if a[1] == 0:
			print(2)
		else:
			print(1)
	elif b[0] == 0:
		print(1)
	else:
		print(2)


from __future__ import division, print_function
import os
import 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
sys.setrecursionlimit(10 ** 8)
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')
try:
	FILE_POINTER = open('input.inpt')
	input = FILE_POINTER.readline
except:
	FILE_POINTER = None
t = int(input())
for _ in range(t):
	n = int(input())
	s = input().strip()
	ro = 0
	re = 0
	bo = 0
	be = 0
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2 == 0:
				re += 1
			else:
				ro += 1
		elif int(s[i]) % 2 == 0:
			be += 1
		else:
			bo += 1
	if n % 2:
		if ro > 0:
			win = 1
		else:
			win = 2
	elif be > 0:
		win = 2
	else:
		win = 1
	print(win)
if FILE_POINTER:
	FILE_POINTER.close()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, list(input())))
	if n % 2:
		can = False
		for i in range(0, n, 2):
			if a[i] % 2:
				print(1)
				can = True
				break
		if not can:
			print(2)
	else:
		can = False
		for i in range(1, n, 2):
			if a[i] % 2 == 0:
				print(2)
				can = True
				break
		if not can:
			print(1)


for _ in range(int(input())):
	input()
	n = input()
	if len(n) % 2 == 0:
		for i in range(1, len(n), 2):
			if int(n[i]) % 2 == 0:
				print(2)
				break
		else:
			print(1)
	else:
		for i in range(0, len(n), 2):
			if int(n[i]) % 2 == 1:
				print(1)
				break
		else:
			print(2)


from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	s = list(map(int, list(stdin.readline()[:-1])))
	if n % 2 == 1:
		ans = 2
		for i in range(0, n, 2):
			if s[i] % 2 == 1:
				ans = 1
		print(ans)
	else:
		ans = 1
		for i in range(1, n, 2):
			if s[i] % 2 == 0:
				ans = 2
		print(ans)


for query in range(int(input())):
	m = int(input())
	n = [int(x) for x in list(input().strip())]
	mybool = False
	if m % 2 == 0:
		for x in range(1, m, 2):
			if n[x] % 2 == 0:
				mybool = True
		if mybool:
			print(2)
		else:
			print(1)
	else:
		for x in range(0, m, 2):
			if n[x] % 2 == 1:
				mybool = True
		if mybool:
			print(1)
		else:
			print(2)


(T,) = map(int, input().split())
for t in range(T):
	(N,) = map(int, input().split())
	s = input().strip()
	if N % 2:
		f = 2
		for i in range(0, N, 2):
			c = s[i]
			if int(c) % 2:
				f = 1
				break
		print(f)
	else:
		f = 1
		for i in range(1, N, 2):
			c = s[i]
			if int(c) % 2 == 0:
				f = 2
				break
		print(f)


def play_raze(x):
	for (p, v) in enumerate(x):
		if p % 2 == 0 and v % 2 == 0 and (v != -1):
			x[p] = -1
			break
	else:
		for (p, v) in enumerate(x):
			if p % 2 == 0 and v != -1:
				x[p] = -1
				break
	return x

def play_breach(x):
	first_even_not_marked = -1
	for (p, v) in enumerate(x):
		if p % 2 != 0 and v % 2 != 0 and (v != -1):
			x[p] = -1
			break
	else:
		for (p, v) in enumerate(x):
			if p % 2 != 0 and v != -1:
				x[p] = -1
				break
	return x

def get_winner(x):
	for v in x:
		if v != -1:
			if v % 2 == 0:
				return 2
			else:
				return 1
n = int(input())
for i in range(n):
	n_size = int(input())
	n = [int(v) for v in input()]
	marked_positions = 0
	is_raze_turn = True
	while True:
		if marked_positions == n_size - 1:
			print(get_winner(n))
			break
		if is_raze_turn:
			play_raze(n)
			marked_positions += 1
			is_raze_turn = False
		else:
			play_breach(n)
			marked_positions += 1
			is_raze_turn = True


def main():
	n = int(input())
	s = input()
	if n % 2 == 0:
		for i in s[1::2]:
			if i in '24680':
				print(2)
				break
		else:
			print(1)
	else:
		for i in s[::2]:
			if i in '13579':
				print(1)
				break
		else:
			print(2)
	return
tests = int(input())
for _ in range(tests):
	main()


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = tuple(map(int, input()))
		if n == 1:
			if s[0] & 1:
				print(1)
			else:
				print(2)
		else:
			flag = n & 1
			saki = sum([se & 1 for se in s[::2]])
			ato = sum([not se & 1 for se in s[1::2]])
			if flag:
				if saki:
					print(1)
				else:
					print(2)
			elif ato:
				print(2)
			else:
				print(1)
main()


t = int(input())
for _ in range(0, t):
	n = int(input())
	a = str(input())
	if n % 2 == 0:
		a = a[1::2]
		if '0' in a or '2' in a or '4' in a or ('6' in a) or ('8' in a):
			print(2)
		else:
			print(1)
	else:
		a = a[::2]
		if '1' in a or '3' in a or '5' in a or ('7' in a) or ('9' in a):
			print(1)
		else:
			print(2)


t = int(input())
results = []
for _ in range(t):
	odd_odd = []
	odd_even = []
	even_odd = []
	even_even = []
	n = int(input())
	digits = input()
	for i in range(n):
		if i % 2 == 0:
			if int(digits[i]) % 2 == 0:
				odd_even.append(digits[i])
			else:
				odd_odd.append(digits[i])
		elif int(digits[i]) % 2 == 0:
			even_even.append(digits[i])
		else:
			even_odd.append(digits[i])
	if len(odd_odd) + len(odd_even) > len(even_odd) + len(even_even):
		if len(odd_odd) >= 1:
			results.append(1)
		else:
			results.append(2)
	elif len(even_even) >= 1:
		results.append(2)
	else:
		results.append(1)
for j in range(t):
	print(results[j])


for _ in range(int(input())):
	_ = input()
	nums = [int(ch) for ch in input()]
	even_pos = [nums[ch] for ch in range(1, len(nums), 2)]
	odd_pos = [nums[ch] for ch in range(0, len(nums), 2)]
	if len(nums) % 2 == 0:
		check = False
		for i in even_pos:
			if i % 2 == 0:
				check = True
				break
			else:
				continue
		if check == True:
			print(2)
		else:
			print(1)
	else:
		check = False
		for i in odd_pos:
			if i % 2 == 0:
				continue
			else:
				check = True
				break
		if check == True:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(t):
	n = int(input())
	v = input()
	count = 0
	start = (n + 1) % 2
	i = (n + 1) % 2
	while count == 0 and i < n:
		if int(v[i]) % 2 == n % 2:
			count += 1
		i += 2
	print((n % 2 + count) % 2 + 1)


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

def ii():
	return int(input())
testcases = int(input())
for t in range(testcases):
	n = ii()
	l = input()
	if n % 2 == 1:
		win = 2
		for i in range(0, n, 2):
			if int(l[i]) % 2 == 1:
				win = 1
	if n % 2 == 0:
		win = 1
		for i in range(1, n, 2):
			if int(l[i]) % 2 == 0:
				win = 2
	print(win)


t = int(input())
for _ in range(t):
	m = int(input())
	n = int(input())
	a = list(str(n))
	flag = False
	if m % 2 != 0:
		for i in range(0, m, 2):
			if int(a[i]) % 2 != 0:
				flag = True
				break
		if flag == True:
			print(1)
		else:
			print(2)
	else:
		for i in range(1, m, 2):
			if int(a[i]) % 2 == 0:
				flag = True
				break
		if flag == True:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	string = input()
	flag = 0
	for i in range(1, len(string), 2):
		if int(string[i]) % 2 == 0:
			flag = 1
			break
	flag2 = 0
	for i in range(0, len(string), 2):
		if int(string[i]) % 2 == 1:
			flag2 = 1
			break
	if len(string) % 2 == 1:
		if flag2 == 1:
			print(1)
		else:
			print(2)
		continue
	if flag == 1:
		print(2)
	else:
		print(1)


def testcase():
	n = int(input())
	data = input()
	if n & 1 == 0:
		for i in range(1, n, 2):
			x = ord(data[i]) - ord('0')
			if x & 1 == 0:
				print(2)
				return
		print(1)
		return
	else:
		for i in range(0, n, 2):
			x = ord(data[i]) - ord('0')
			if x & 1 == 1:
				print(1)
				return
		print(2)
		return
	return
t = int(input())
for _ in range(t):
	testcase()


for i in range(int(input())):
	lst = list()
	n = int(input())
	num = input()
	for i in num:
		lst.append(int(i))
	c = 0
	c1 = 0
	if n == 1:
		if int(num) % 2 == 0:
			print(2)
			continue
		else:
			print(1)
			continue
	for i in range(n):
		if lst[i] % 2 != 0 and (i + 1) % 2 != 0:
			c = c + 1
		elif lst[i] % 2 == 0 and (i + 1) % 2 == 0:
			c1 = c1 + 1
	if n % 2 != 0 and c != 0:
		print(1)
		continue
	elif n % 2 != 0 and c <= 0:
		print(2)
	elif n % 2 == 0 and c1 != 0:
		print(2)
	elif n % 2 == 0 and c1 <= 0:
		print(1)


for _ in ' ' * int(input()):
	(ro, be) = (0, 0)
	n = int(input())
	a = list(map(int, input()))
	for i in range(n):
		if i % 2:
			if a[i] % 2 == 0:
				be += 1
		elif a[i] % 2 == 1:
			ro += 1
	if n % 2 == 1:
		if ro > 0:
			print(1)
		else:
			print(2)
	elif be > 0:
		print(2)
	else:
		print(1)


t = int(input())
for tt in range(t):
	n = int(input())
	s = list(map(lambda x: int(x) % 2, input()[1 - n % 2::2]))
	if n % 2 == 1:
		if 1 in s:
			print(1)
		else:
			print(2)
	elif 0 in s:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	ro = 0
	re = 0
	bo = 0
	be = 0
	for i in range(1, n + 1):
		el = int(s[i - 1])
		if i % 2 == 0:
			if el % 2 == 0:
				be += 1
			else:
				bo += 1
		elif el % 2 == 0:
			re += 1
		else:
			ro += 1
	bn = int((n - 1) / 2)
	rn = n - 1 - bn
	while rn > 0:
		if re > 0:
			re -= 1
		elif ro > 0:
			ro -= 1
		rn -= 1
	while bn > 0:
		if bo > 0:
			bo -= 1
		elif be > 0:
			be -= 1
		bn -= 1
	b = ro + bo < be + re
	print(b + 1)


import sys
import collections as cc
import bisect as bi
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	s = list(input().strip())
	oneod = oneev = twood = twoev = 0
	for i in range(n):
		if i % 2 == 0:
			if int(s[i]) % 2 == 0:
				oneev += 1
			else:
				oneod += 1
		elif int(s[i]) % 2 == 0:
			twoev += 1
		else:
			twood += 1
	if n % 2 == 0:
		if twoev > 0:
			print(2)
		else:
			print(1)
	elif oneod > 0:
		print(1)
	else:
		print(2)


tc = int(input())
while tc:
	n = int(input())
	str_num = input()
	raze = (n + 1) // 2
	breach = n // 2
	razeFoundOdd = False
	for n in str_num[::2]:
		if int(n) % 2:
			razeFoundOdd = True
			break
	breachFoundEven = False
	for n in str_num[1::2]:
		if not int(n) % 2:
			breachFoundEven = True
			break
	if raze > breach:
		if razeFoundOdd:
			print(1)
		else:
			print(2)
	elif breachFoundEven:
		print(2)
	else:
		print(1)
	tc -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().strip()]
	raze = [0, 0]
	breach = [0, 0]
	for i in range(0, n, 2):
		if a[i] % 2:
			raze[0] += 1
		else:
			raze[1] += 1
	for i in range(1, n, 2):
		if a[i] % 2:
			breach[0] += 1
		else:
			breach[1] += 1
	if n % 2 == 0:
		if breach[1]:
			print(2)
		else:
			print(1)
	elif raze[0]:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	Raze = 0
	Breach = 0
	for i in range(n):
		if i % 2 == 0 and (ord(s[i]) - ord('0')) % 2 == 1:
			Raze = 1
		if i % 2 and (ord(s[i]) - ord('0')) % 2 == 0:
			Breach = 1
	if n % 2 and Raze:
		print(1)
	elif n % 2:
		print(2)
		continue
	elif n % 2 == 0 and Breach:
		print(2)
	elif n % 2 == 0 and (not Breach):
		print(1)
	else:
		print(2)
		continue


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	n = iinput()
	s = input()
	if n == 1:
		s = int(s)
		if s % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		(odd1, odd2, even1, even2) = (0, 0, 0, 0)
		for i in range(len(s)):
			ch = int(s[i])
			if i % 2 == 0:
				if ch % 2 == 0:
					even1 += 1
				else:
					odd1 += 1
			elif ch % 2 == 0:
				even2 += 1
			else:
				odd2 += 1
		if n % 2 == 1:
			if odd1 > 0:
				print(1)
			else:
				print(2)
		elif even2 > 0:
			print(2)
		else:
			print(1)


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

def ii():
	return int(input())

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

def mi():
	return map(int, input().split())

def out(v):
	print(v)

def spout():
	print(v, end=' ')

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

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
t = ii()
while t:
	t -= 1
	n = ii()
	num = ii()
	f = 0
	if n % 2 == 1:
		for i in range(n):
			if f == 0 and (n - i) % 2 == 1 and (num % 10 % 2 == 1):
				f = 1
				break
			num //= 10
		if f == 1:
			print(1)
		else:
			print(2)
	else:
		for i in range(n):
			if f == 0 and (n - i) % 2 == 0 and (num % 10 % 2 == 0):
				f = 1
				break
			num //= 10
		if f == 1:
			print(2)
		else:
			print(1)


def func(l, n):
	a = str(n)
	if l % 2 != 0:
		for i in a[::2]:
			if int(i) % 2 != 0:
				print(1)
				return
		print(2)
		return
	else:
		flag = False
		for i in a[1::2]:
			if int(i) % 2 == 0:
				print(2)
				return
		print(1)
		return
t = int(input())
for _ in range(t):
	l = int(input())
	num = int(input())
	func(l, num)


from collections import *
for i in range(int(input())):
	x = int(input())
	k = list(input().strip())
	n = list(map(int, k))
	odd = []
	eve = []
	(oc1, ec1) = (0, 0)
	(oc2, ec2) = (0, 0)
	if x == 1:
		if n[0] % 2:
			print(1)
		else:
			print(2)
	else:
		for i in range(x):
			if not i % 2:
				odd.append(n[i])
				if n[i] % 2:
					oc1 += 1
				else:
					ec1 += 1
			else:
				eve.append(n[i])
				if n[i] % 2:
					oc2 += 1
				else:
					ec2 += 1
		flag = 0
		while x > 1:
			if flag == 0:
				if ec1:
					ec1 -= 1
				else:
					oc1 -= 1
				flag = 1
			elif flag == 1:
				if oc2:
					oc2 -= 1
				else:
					ec2 -= 1
				flag = 0
			x -= 1
		if oc1 or oc2:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input()))
	(f1, f2, f3) = (0, 0, 1)
	for i in range(1000):
		f3 = f3 + 1
	ll = []
	for i in range(100):
		ll.append(i)
	for (i, x) in enumerate(l):
		if i & 1:
			if not x & 1:
				f2 = 1
		elif x & 1:
			f1 = 1
	if not n & 1:
		if f2:
			print(2)
		else:
			print(1)
	elif f1:
		print(1)
	else:
		print(2)


rw = int(input())
for wewq in range(rw):
	n = int(input())
	a = list(map(int, list(input())))
	if n % 2 == 1:
		for i in range(n):
			if a[i] % 2 == 1 and i % 2 == 0:
				print(1)
				break
		else:
			print(2)
	if n % 2 == 0:
		for i in range(n):
			if a[i] % 2 == 0 and i % 2 == 1:
				print(2)
				break
		else:
			print(1)


for y in range(int(input())):
	n = int(input())
	st = input()
	lst1 = []
	lst2 = []
	for i in range(n):
		if i % 2 == 0:
			lst1.append(int(st[i]))
		else:
			lst2.append(int(st[i]))
	lst1.sort()
	lst2.sort()
	e1 = e2 = 0
	o1 = o2 = 0
	for i in lst1:
		if i % 2 == 0:
			e1 += 1
		else:
			o1 += 1
	for i in lst2:
		if i % 2 == 0:
			e2 += 1
		else:
			o2 += 1
	if n % 2 != 0:
		if o1 > 0:
			print('1')
		else:
			print('2')
	elif e2 > 0:
		print('2')
	else:
		print('1')


for _ in range(int(input())):
	n = int(input())
	s = input()
	if n % 2 == 0:
		count = 0
		for i in range(1, n, 2):
			b = int(s[i])
			if b % 2 == 0:
				print(2)
				count = 1
				break
		if count == 0:
			print(1)
	else:
		count = 0
		for j in range(0, n, 2):
			a = int(s[j])
			if a % 2 != 0:
				print(1)
				count = 1
				break
		if count == 0:
			print(2)


testcase = int(input())
for test in range(testcase):
	n = int(input())
	string = input()
	if n == 1:
		if int(string) % 2 == 0:
			print('2')
		else:
			print('1')
	else:
		str1 = string[0:n:2]
		str2 = string[1:n:2]
		if n % 2 == 1:
			ch = 2
			for i in str1:
				if int(i) % 2 == 1:
					ch = 1
					break
			print(ch)
		else:
			ch = 1
			for i in str2:
				if int(i) % 2 == 0:
					ch = 2
					break
			print(ch)


t = int(input())
for i in range(t):
	input()
	s = input()
	if len(s) % 2 == 0:
		j = 1
		while j < len(s):
			if int(s[j]) % 2 == 0:
				print('2')
				break
			elif j == len(s) - 1:
				print('1')
			j += 2
	if len(s) % 2 == 1:
		j = 0
		while j < len(s):
			if int(s[j]) % 2 != 0:
				print('1')
				break
			elif j == len(s) - 1:
				print('2')
			j += 2


for i in range(int(input())):
	n = int(input())
	s = input()
	if n % 2:
		if any((int(ch) % 2 for ch in s[::2])):
			print(1)
		else:
			print(2)
	elif all((int(ch) % 2 for ch in s[1::2])):
		print(1)
	else:
		print(2)


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, list(input())))
		odd = sum([1 for i in range(0, n, 2) if a[i] % 2 == 1])
		even = sum([1 for i in range(1, n, 2) if a[i] % 2 == 0])
		if 1:
			if n % 2 == 0 and even > 0:
				print(2)
			elif n % 2 == 0:
				print(1)
			elif n % 2 == 1 and odd > 0:
				print(1)
			elif n % 2 == 1:
				print(2)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	r = []
	b = []
	q = 0
	c = 1
	w = 0
	for i in range(n):
		if (i + 1) % 2 == 1:
			r.append(int(x[i]))
			q = q + 1
		else:
			b.append(int(x[i]))
			w = w + 1
	if q > w:
		for i in range(q):
			if r[i] % 2 == 1:
				print('1')
				c = 0
				break
		if c:
			print('2')
	elif w > q:
		for i in range(w):
			if b[i] % 2 == 0:
				print('2')
				c = 0
				break
		if c:
			print('1')
	elif q % 2 == 0:
		for i in range(w):
			if b[i] % 2 == 0:
				print('2')
				c = 0
				break
		if c:
			print('1')
	else:
		for i in range(w):
			if b[i] % 2 == 0:
				print('2')
				c = 0
				break
		if c:
			print('1')


[(lambda N, n: print((1 if sum((1 for c in n[::2] if int(c) & 1)) else 2) if N & 1 else 2 if sum((1 for c in n[1::2] if int(c) & 1 ^ 1)) else 1))(int(input()), input()) for t in range(int(input()))]


def main():
	n = int(input())
	num = list(input())
	if n % 2 == 0:
		even = False
		for i in range(n):
			if i % 2:
				if int(num[i]) % 2 == 0:
					even = True
					break
		if even:
			print('2')
		else:
			print('1')
	else:
		odd = False
		for i in range(n):
			if i % 2 == 0:
				if int(num[i]) % 2:
					odd = True
					break
		if odd:
			print('1')
		else:
			print('2')
for _ in range(int(input())):
	main()


tests = int(input())
i = 0
while i < tests:
	len_of_array = int(input())
	array = [int(x) for x in input()]
	j = 0
	breech_wins = False
	rays_win = False
	while j < len_of_array:
		if len_of_array % 2 == 0:
			rays_win = True
			if j % 2 != 0:
				if array[j] % 2 == 0:
					print(2)
					break
		else:
			breech_wins = True
			if j % 2 == 0:
				if array[j] % 2 != 0:
					print(1)
					break
		j += 1
	else:
		if rays_win == True:
			print(1)
		elif breech_wins == True:
			print(2)
	i += 1


import collections
t = int(input())
for i in range(t):
	num = int(input())
	l = list(map(int, input()))
	n = len(l)
	r = collections.deque([])
	s = collections.deque([])
	for i in range(n):
		if i % 2 == 0:
			if l[i] % 2 == 0:
				r.appendleft(l[i])
			else:
				r.append(l[i])
		elif l[i] % 2 == 1:
			s.appendleft(l[i])
		else:
			s.append(l[i])
	if len(r) > len(s):
		x = len(s)
		if r[x] % 2:
			print(1)
		else:
			print(2)
	else:
		x = len(r) - 1
		if s[x] % 2:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	num = [int(i) for i in input()]
	(rod, bod, s) = (0, 0, 1)
	for i in num:
		if s:
			rod += i & 1
		else:
			bod += i & 1
		s = 1 - s
	if n & 1:
		print('1' if rod else '2')
	else:
		print('1' if bod == n // 2 else '2')


def digit(n):
	ar = []
	while n > 0:
		ar.append(n % 10)
		n = n // 10
	ar.reverse()
	return ar
x = int(input())
for i in range(0, x):
	m = int(input())
	n = int(input())
	ar = digit(n)
	if m % 2 == 0:
		s = 0
		for j in range(1, m, 2):
			if ar[j] % 2 == 0:
				s = 1
				break
		if s == 1:
			print(2)
		else:
			print(1)
	else:
		s = 0
		for j in range(0, m, 2):
			if ar[j] % 2 != 0:
				s = 1
				break
		if s == 1:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(t):
	n = int(input())
	string = input()
	ls = list(string)
	count = 0
	if n % 2 == 0:
		for j in range(n):
			if j % 2 != 0 and int(ls[j]) % 2 == 0:
				count = 1
				break
	else:
		for j in range(n):
			if j % 2 == 0 and int(ls[j]) % 2 != 0:
				count = 0
				break
			else:
				count = 1
	if count == 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	a = int(input())
	l = int(input())
	s = str(l)
	r = 0
	b = 0
	for i in range(1, a + 1):
		if i % 2 and int(s[i - 1]) % 2:
			r = r + 1
		elif i % 2 == 0 and int(s[i - 1]) % 2 == 0:
			b = b + 1
	if a % 2 == 0:
		if b:
			print(2)
		else:
			print(1)
	elif r:
		print(1)
	else:
		print(2)


matches = int(input())
for i in range(matches):
	size = int(input())
	num = input()
	raze = len([x for x in [int(num[x]) for x in range(len(num)) if x % 2 == 0] if x % 2 == 1])
	breach = len([x for x in [int(num[x]) for x in range(len(num)) if x % 2 == 1] if x % 2 == 0])
	if size % 2 == 0:
		if breach:
			print(2)
		else:
			print(1)
	elif raze:
		print(1)
	else:
		print(2)


def solve():
	n = int(input())
	num = input()
	o_o = list(map(int, [num[i] for i in range(0, len(num), 2) if int(num[i]) % 2 == 1]))
	o_e = list(map(int, [num[i] for i in range(0, len(num), 2) if int(num[i]) % 2 != 1]))
	e_o = list(map(int, [num[i] for i in range(1, len(num), 2) if int(num[i]) % 2 == 1]))
	e_e = list(map(int, [num[i] for i in range(1, len(num), 2) if int(num[i]) % 2 != 1]))
	e = e_o + e_e
	o = o_e + o_o
	if len(e) == len(o):
		if e[-1] % 2 == 0:
			print(2)
		else:
			print(1)
	elif o[-1] % 2 == 0:
		print(2)
	else:
		print(1)
t = int(input())
while t:
	solve()
	t -= 1


t = int(input())
for x in range(0, t):
	r = []
	b = []
	nr = 0
	nb = 0
	n = int(input())
	num = int(input())
	while num != 0:
		t = num % 10
		if n % 2 == 0:
			b.append(int(t))
		else:
			r.append(int(t))
		num = num // 10
		n -= 1
	for i in r:
		if i % 2 != 0:
			nr += 1
	for i in b:
		if i % 2 == 0:
			nb += 1
	if len(r) > len(b):
		if nr > 0:
			print('1')
		else:
			print('2')
	elif nb > 0:
		print('2')
	else:
		print('1')


from functools import *
import math
from collections import *
from sys import stdin, stdout
inp = stdin.readline
out = stdout.write

def mi():
	return map(int, inp().split())

def li():
	return list(mi())

def ii():
	return int(inp())

def main():
	for _ in range(ii()):
		n = ii()
		num = input()
		num = list(num)
		num = list(map(int, num))
		ans = 2
		if n % 2 == 1:
			for i in range(0, n, 2):
				if num[i] % 2 != 0:
					ans = 1
					break
		else:
			for i in range(1, n, 2):
				if num[i] % 2 == 0:
					break
			else:
				ans = 1
		print(ans)
main()


def whowins(num, n):
	if n % 2 == 0:
		idx = 1
		while idx < n:
			if int(num[idx]) % 2 == 0:
				print('2')
				return
			idx += 2
		print('1')
		return
	else:
		idx = 0
		while idx < n:
			if int(num[idx]) % 2 != 0:
				print('1')
				return
			idx += 2
		print('2')
		return
t = int(input())
for _ in range(t):
	n = int(input())
	num = input()
	if __name__ == '__main__':
		whowins(num, n)


for _ in range(int(input())):
	n = int(input())
	s = input()
	if n % 2 == 0:
		no = 0
		for i in range(1, n, 2):
			if int(s[i]) & 1:
				no += 1
		if no == n // 2:
			print(1)
		else:
			print(2)
	else:
		ne = 0
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 0:
				ne += 1
		if ne == n // 2 + 1:
			print(2)
		else:
			print(1)


import sys
import math
t = int(input())
digits = []
numbers = []
for game in range(t):
	digit = int(input())
	number = input()
	digits.append(digit)
	numbers.append(number)
RAZE = 1
BREACH = 2
for number in numbers:
	even_digits = ''
	odd_digits = ''
	for i in range(len(number)):
		if i % 2 == 0:
			odd_digits += number[i]
		else:
			even_digits += number[i]
	if len(number) % 2 == 0:
		if '2' in even_digits or '4' in even_digits or '6' in even_digits or ('8' in even_digits) or ('0' in even_digits):
			print(BREACH)
		else:
			print(RAZE)
	elif '1' in odd_digits or '3' in odd_digits or '5' in odd_digits or ('7' in odd_digits) or ('9' in odd_digits):
		print(RAZE)
	else:
		print(BREACH)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	ner = neb = 0
	nor = nob = 0
	ch = input()
	for i in range(n):
		a = int(ch[i])
		if (i + 1) % 2 == 0:
			if a % 2 == 0:
				neb += 1
			else:
				nob += 1
		elif a % 2 == 0:
			ner += 1
		else:
			nor += 1
	if n % 2 == 0:
		if neb > 0:
			print(2)
		else:
			print(1)
	elif nor > 0:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	n = int(input())
	str1 = list(input())
	rase = list(map(int, str1[::2]))
	brich = list(map(int, str1[1::2]))
	if len(str1) % 2 == 0:
		brich.sort(key=lambda x: x % 2 == 0)
		if brich[-1] % 2 == 1:
			print(1)
		else:
			print(2)
	else:
		rase.sort(key=lambda x: x % 2 == 1)
		if rase[-1] % 2 == 1:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(t):
	n = int(input())
	value = input()
	if n & 1 == 1:
		two_wins = True
		for (index, v) in enumerate(value):
			if index + 1 & 1 == 1:
				if int(v) & 1 == 1:
					two_wins = False
					break
			elif not two_wins and int(v) & 1 == 0:
				two_wins = True
		if two_wins:
			print(2)
		else:
			print(1)
	else:
		one_wins = True
		for (index, v) in enumerate(value):
			if index + 1 & 1 == 0:
				if int(v) & 1 == 0:
					one_wins = False
					break
			elif not one_wins and int(v) & 1 == 1:
				one_wins = True
		if one_wins:
			print(1)
		else:
			print(2)


t = int(input())
for i in range(t):
	n = int(input())
	s = str(input())
	a = len(s)
	if a % 2 == 0:
		x = 0
		for j in range(a):
			if j % 2 == 1:
				if int(s[j]) % 2 == 0:
					x += 1
		if x > 0:
			print(2)
		else:
			print(1)
	else:
		x = 0
		for j in range(a):
			if j % 2 == 0:
				if int(s[j]) % 2 == 1:
					x += 1
		if x > 0:
			print(1)
		else:
			print(2)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque
import math

def main():
	for t in range(int(input())):
		n = int(input())
		a = [int(i) for i in input().strip()]
		if n % 2 == 0:
			(o, e) = (0, 0)
			for i in range(1, n, 2):
				if a[i] % 2 == 0:
					e += 1
				else:
					o += 1
			if e == 0:
				print(1)
			else:
				print(2)
		else:
			(o, e) = (0, 0)
			for i in range(0, n, 2):
				if a[i] % 2 == 0:
					e += 1
				else:
					o += 1
			if o == 0:
				print(2)
			else:
				print(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()


from collections import *
for i in range(int(input())):
	(n, s) = (int(input()), [int(x) for x in input()])
	raze = [x for (i, x) in enumerate(s) if not i % 2 and x % 2]
	breach = [x for (i, x) in enumerate(s) if i % 2 and (not x % 2)]
	if n % 2:
		if len(raze):
			print(1)
		else:
			print(2)
	elif len(breach):
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	if n % 2 == 1:
		if len([int(s[i]) for i in range(0, n, 2) if int(s[i]) % 2 == 1]) > 0:
			print(1)
		else:
			print(2)
	elif len([int(s[i]) for i in range(1, n, 2) if int(s[i]) % 2 == 0]) > 0:
		print(2)
	else:
		print(1)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = list(map(int, input()))
	v1 = list()
	v2 = list()
	for i in range(0, n):
		if i & 1:
			v2.append(int(s[i]))
		else:
			v1.append(int(s[i]))
	ok = 0
	if n & 1:
		for i in range(0, len(v1)):
			if v1[i] & 1:
				ok = 1
				break
		if ok == 0:
			ok = 2
	else:
		for i in range(0, len(v2)):
			if v2[i] % 2 == 0:
				ok = 2
				break
		if ok == 0:
			ok = 1
	if ok == 1:
		print('1')
	else:
		print('2')


import sys
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	raze_digits = set(map(int, s[0::2]))
	breach_digits = set(map(int, s[1::2]))
	if n % 2 == 1:
		if any((digit % 2 == 1 for digit in raze_digits)):
			print(1)
		else:
			print(2)
	elif any((digit % 2 == 0 for digit in breach_digits)):
		print(2)
	else:
		print(1)


t = int(input())
while t > 0:
	d = int(input())
	n = input()
	odd = False
	even = False
	for i in range(1, d + 1):
		if i % 2 == 1:
			odd = odd or int(n[i - 1]) % 2 == 1
		else:
			even = even or int(n[i - 1]) % 2 == 0
	if d % 2 == 1:
		if odd == True:
			print(1)
		else:
			print(2)
	elif even == True:
		print(2)
	else:
		print(1)
	t -= 1


def go():
	n = int(input())
	m = input()
	if n % 2 == 0:
		for i in range(n):
			if i % 2 != 0 and int(m[i]) % 2 == 0:
				print(2)
				return
		print(1)
	else:
		for i in range(n):
			if i % 2 == 0 and int(m[i]) % 2 == 1:
				print(1)
				return
		print(2)
for tt in range(int(input())):
	go()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	is_even = any([int(s[i]) % 2 == 0 for i in range(1, n, 2)])
	is_odd = any([int(s[i]) & 1 for i in range(0, n, 2)])
	if n % 2 == 0 and is_even or (n & 1 and (not is_odd)):
		print(2)
	else:
		print(1)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
mod = 998244353
INF = float('inf')
for t in range(int(data())):
	n = int(data())
	a = data()
	if n % 2 == 0:
		k = 0
		for i in range(1, n, 2):
			if int(a[i]) % 2 == 0:
				k = 1
		if k:
			out(2)
		else:
			out(1)
	else:
		k = 0
		for i in range(0, n, 2):
			if int(a[i]) % 2 == 1:
				k = 1
		if k:
			out(1)
		else:
			out(2)


for test in range(int(input())):
	n = int(input())
	l = list(input())
	raze = 0
	breach = 0
	if n % 2 == 0:
		raze = int(n / 2)
		breach = int(n / 2) - 1
	else:
		raze = int(n / 2)
		breach = int(n / 2)
	razeeven = 0
	razeodd = 0
	breacheven = 0
	breachodd = 0
	for i in range(len(l)):
		if int(l[i]) % 2 == 0 and (i + 1) % 2 == 0:
			breacheven += 1
			continue
		if int(l[i]) % 2 != 0 and (i + 1) % 2 == 0:
			breachodd += 1
			continue
		if int(l[i]) % 2 == 0 and (i + 1) % 2 != 0:
			razeeven += 1
			continue
		if int(l[i]) % 2 != 0 and (i + 1) % 2 != 0:
			razeodd += 1
			continue
	if n % 2 == 0:
		while breachodd > 0:
			if breach < 1:
				break
			breachodd -= 1
			breach -= 1
		if breach > 0:
			while breacheven > 0:
				if breach < 1:
					break
				breach -= 1
				breach -= 1
		if breacheven > 0:
			print(2)
		else:
			print(1)
	else:
		while razeeven > 0:
			if raze < 1:
				break
			razeeven -= 1
			raze -= 1
		if raze > 0:
			while razeodd > 0:
				if raze < 1:
					break
				razeodd -= 1
				raze -= 1
		if razeodd > 0:
			print(1)
		else:
			print(2)


def solve():
	n = int(input())
	s = input()
	even_pos = {'e': 0, 'o': 0}
	odd_pos = {'e': 0, 'o': 0}
	for i in range(n):
		if (i + 1) % 2 == 0:
			if int(s[i]) % 2 == 0:
				even_pos['e'] += 1
			else:
				even_pos['o'] += 1
		elif int(s[i]) % 2 == 0:
			odd_pos['e'] += 1
		else:
			odd_pos['o'] += 1
	i = n
	flag = 'r'
	while i > 1:
		if flag == 'r':
			if odd_pos['e'] > 0:
				odd_pos['e'] -= 1
			else:
				odd_pos['o'] -= 1
			flag = 'b'
		else:
			if even_pos['o'] > 0:
				even_pos['o'] -= 1
			else:
				even_pos['e'] -= 1
			flag = 'r'
		i -= 1
	if even_pos['e'] == 1 or odd_pos['e'] == 1:
		return 2
	else:
		return 1
for _ in range(int(input())):
	print(solve())


from math import *
from cmath import *
from decimal import *
from fractions import *
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	ok = 1
	if n % 2:
		for a in range(0, n, 2):
			if int(s[a]) % 2:
				print(1)
				ok = 0
				break
		if ok:
			print(2)
	else:
		for a in range(1, n, 2):
			if int(s[a]) % 2 == 0:
				print(2)
				ok = 0
				break
		if ok:
			print(1)


for _ in range(int(input())):
	n = int(input())
	k = int(input())
	j = str(k)
	if n % 2 == 0:
		f = 0
		for i in range(n):
			if int(j[i]) % 2 == 0 and i % 2 != 0:
				f = 1
				break
		if f == 1:
			print('2')
		else:
			print('1')
	else:
		f = 0
		for i in range(n):
			if int(j[i]) % 2 != 0 and i % 2 == 0:
				f = 1
				break
		if f == 1:
			print('1')
		else:
			print('2')


import sys, math
try:
	(sys.stdin, sys.stdout) = (open('input.txt', 'r'), open('out.txt', 'w'))
except:
	pass
from sys import stdin, stdout
mod = int(1000000000.0 + 7)
from statistics import mode
from collections import *
from math import ceil, floor, inf, factorial, gcd, log2, sqrt, log
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()

def lcm(a, b):
	return a * b // gcd(a, b)

def setbits(n):
	return bin(n).count('1')

def resetbits(n):
	return bin(n).count('0')

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r):
	(num, den) = (1, 1)
	r = min(n, n - r)
	for i in range(r):
		num *= n - i
		den *= i + 1
	return num // den

def ncr_p(n, r, p):
	(num, den) = (1, 1)
	r = min(r, n - r)
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * modinv(den, p) % p

def isPrime(num):
	if num <= 1:
		return False
	if num == 2 or n == 3:
		return True
	if num % 2 == 0 or num % 3 == 0:
		return False
	m = int(num ** 0.5) + 1
	for i in range(5, m, 6):
		if num % i == 0 or num % (i + 2) == 0:
			return False
	return True

def bin_search(s, low, high, val):
	while low <= high:
		mid = low + (high - low) // 2
		if s[mid] == val:
			return mid
		elif s[mid] < val:
			low = mid + 1
		else:
			high = mid - 1
	return -1

def sumofdigit(num):
	count = 0
	while num:
		count += num % 10
		num //= 10
	return count

def inputmatrix():
	(r, c) = iia()
	mat = [0] * r
	for i in range(r):
		mat[i] = iia()
	return (r, c, mat)

def prefix_sum(n, s):
	for i in range(1, n):
		s[i] += s[i - 1]
	return s

def binomial(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def divisors(n):
	res = []
	for i in range(1, ceil(sqrt(n)) + 1):
		if n % i == 0:
			if i == n // i:
				res.append(i)
			else:
				res.append(i)
				res.append(n // i)
	return res
for _ in range(ii1()):
	n = ii1()
	s = is1()
	(raze, other) = ([], [])
	flag = False
	if n % 2 == 0:
		for i in range(n):
			if i % 2 == 0:
				raze.append(s[i])
			else:
				other.append(s[i])
		for i in range(0, 11, 2):
			if str(i) in other:
				flag = True
		if flag:
			print(2)
		else:
			print(1)
	else:
		for i in range(n):
			if i % 2 == 0:
				raze.append(s[i])
			else:
				other.append(s[i])
		for i in range(1, 10, 2):
			if str(i) in raze:
				flag = True
		if flag:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input()))
	if n % 2 == 0:
		f = 0
		for i in range(1, n, 2):
			if s[i] % 2 == 0:
				f = 1
		if f == 1:
			print(2)
		else:
			print(1)
	else:
		f = 0
		for i in range(0, n, 2):
			if s[i] % 2 == 1:
				f = 1
		if f == 1:
			print(1)
		else:
			print(2)


def wins(s):
	if len(s) % 2 == 0:
		start = 1
		lookingFor = 0
	else:
		start = 0
		lookingFor = 1
	found = False
	for i in range(start, len(s), 2):
		if int(s[i]) % 2 == lookingFor:
			found = True
			break
	if lookingFor == 0:
		if found:
			return 2
		return 1
	else:
		if found:
			return 1
		return 2
T = int(input())
for t in range(T):
	n = input()
	s = input()
	print(wins(s))


for _ in range(int(input())):
	n = int(input())
	s = input()
	a1 = a2 = 0
	rayz = s[::2]
	bri = s[1::2]
	if n % 2:
		if any((int(i) % 2 for i in rayz)):
			print(1)
		else:
			print(2)
	elif any((int(i) % 2 == 0 for i in bri)):
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	k = int(input())
	x = n
	even = []
	odd = []
	while k > 0:
		if x % 2 == 0:
			even.append(k % 10)
		else:
			odd.append(k % 10)
		k //= 10
		x -= 1
	ok = True
	if n % 2 == 0:
		for i in range(len(even)):
			if even[i] % 2 == 0:
				ok = False
	else:
		flag = 0
		for i in range(len(odd)):
			if odd[i] % 2 == 0:
				flag += 1
		if flag == len(odd):
			ok = False
	if ok:
		print('1')
	else:
		print('2')


tests = int(input())
for test in range(tests):
	n = int(input())
	a = [int(i) for i in input()]
	if n % 2 == 0:
		f = False
		for i in range(1, n, 2):
			if a[i] % 2 == 0:
				f = True
				break
		if f:
			print(2)
		else:
			print(1)
	else:
		f = False
		for i in range(0, n, 2):
			if a[i] % 2 == 1:
				f = True
				break
		if f:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	t = int(input())
	d = input()
	if t % 2 == 0:
		val = 1
		for num in range(1, t, 2):
			if int(d[num]) % 2 == 0:
				val = 2
				break
	else:
		val = 2
		for num in range(0, t, 2):
			if int(d[num]) % 2 != 0:
				val = 1
				break
	print(val)


def solve(x, y):
	if x <= 2:
		return '2' if int(y) % 2 == 0 else '1'
	elif x % 2 == 1:
		for i in range(0, len(y), 2):
			if int(y[i]) % 2 == 1:
				return '1'
		return '2'
	else:
		for i in range(1, len(y), 2):
			if int(y[i]) % 2 == 0:
				return '2'
		return '1'
n = int(input())
for i in range(n):
	m = int(input())
	o = input()
	result = solve(m, o)
	print(result)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	s = input().rstrip()
	if len(s) % 2 == 0:
		ben_wins = False
		for ch in s[1::2]:
			if int(ch) % 2 == 0:
				ben_wins = True
	else:
		ben_wins = True
		for ch in s[0::2]:
			if int(ch) % 2 == 1:
				ben_wins = False
	if ben_wins:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	a = str(input())
	if n & 1:
		x = 2
		for i in range(0, n, 2):
			if int(a[i]) & 1:
				x = 1
				break
		print(x)
	else:
		x = 1
		for i in range(1, n, 2):
			if int(a[i]) % 2 == 0:
				x = 2
				break
		print(x)


for x in range(int(input())):
	n = int(input())
	l = list(map(int, input()))
	if n % 2 == 0:
		ans = 1
		for i in range(1, n, 2):
			if int(l[i]) % 2 == 0:
				ans = 2
				break
	else:
		ans = 2
		for i in range(0, n, 2):
			if int(l[i]) % 2 != 0:
				ans = 1
				break
	print(ans)


def algo(n, k):
	if n == 1:
		return 2 if int(k) % 2 == 0 else 1
	even = 0
	odd = 0
	s = str(k)
	if n % 2 == 0:
		for i in range(1, n, 2):
			x = int(s[i])
			even += 1 if x % 2 == 0 else 0
			odd += 1 if x % 2 == 1 else 0
		if even != 0:
			return 2
		else:
			return 1
	else:
		for i in range(0, n, 2):
			x = int(s[i])
			even += 1 if x % 2 == 0 else 0
			odd += 1 if x % 2 == 1 else 0
		if odd != 0:
			return 1
		else:
			return 2
for _ in range(int(input())):
	n = int(input())
	k = int(input())
	ans = algo(n, k)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	digits = [int(i) for i in input()]
	raze = [digits[i] % 2 for i in range(0, n, 2)]
	breach = [digits[i] % 2 for i in range(1, n, 2)]
	if n % 2 == 0:
		print(2 if 0 in breach else 1)
	else:
		print(1 if 1 in raze else 2)


t = int(input())

def gdig(num):
	d = []
	if num < 10:
		d.append(num)
	else:
		d = gdig(num // 10)
		d.append(num % 10)
	return d
for k in range(t):
	n = int(input())
	x = int(input())
	digits = []
	digits = gdig(x)
	b = False
	r = False
	if n % 2 == 0:
		for i in range(len(digits)):
			if i % 2 != 0 and digits[i] % 2 == 0:
				b = True
		if not b:
			r = True
	else:
		for i in range(len(digits)):
			if i % 2 == 0 and digits[i] % 2 != 0:
				r = True
		if not r:
			b = True
	if b:
		print(2)
	if r:
		print(1)


import math
t = int(input())
for i in range(t):
	n = int(input())
	num = input()
	if n == 1:
		if int(num) % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	if n % 2 == 0:
		flag = False
		for j in range(1, n, 2):
			if int(num[j]) % 2 == 0:
				flag = True
				break
		if flag:
			print(2)
		else:
			print(1)
	else:
		flag = False
		for j in range(0, n, 2):
			if int(num[j]) % 2 == 1:
				flag = True
				break
		if flag:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	d = int(input())
	n = input()
	t = [int(x) for x in n]
	(flag_a, flag_b) = (0, 0)
	(a, b) = ([], [])
	for x in range(d):
		if x % 2 == 0:
			a.append(t[x])
			if t[x] % 2 != 0:
				flag_a = 1
		else:
			b.append(t[x])
			if t[x] % 2 == 0:
				flag_b = 1
	if d % 2 == 0:
		if flag_b == 1:
			print(2)
		else:
			print(1)
	elif flag_a == 1:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(input())
	for i in range(n):
		s[i] = int(s[i])
	if n % 2 == 0:
		even = 0
		for i in range(n):
			if i % 2 != 0:
				if s[i] % 2 == 0:
					even = 1
					break
		if even == 0:
			print(1)
		else:
			print(2)
	else:
		odd = 0
		for i in range(n):
			if i % 2 == 0:
				if s[i] % 2 != 0:
					odd = 1
					break
		if odd == 0:
			print(2)
		else:
			print(1)


t = int(input())
for _ in range(t):
	result = 0
	n = int(input())
	num = int(input())
	digits = [int(i) for i in str(num)]
	if n % 2 == 0:
		for j in range(1, n, 2):
			if digits[j] % 2 == 0:
				result = 2
				break
		if result == 0:
			result = 1
	else:
		for j in range(0, n, 2):
			if digits[j] % 2 != 0:
				result = 1
				break
		if result == 0:
			result = 2
	print(result)


for _ in range(int(input())):
	n = int(input())
	a = input()
	a1 = 0
	a2 = 0
	for i in range(n):
		if i % 2 == 0:
			if int(a[i]) % 2 == 0:
				a1 += 1
		elif int(a[i]) % 2 == 0:
			a2 += 1
	if n % 2 == 1:
		if a1 <= n // 2:
			print(1)
		else:
			print(2)
	elif a2 > 0:
		print(2)
	else:
		print(1)


tst = int(input())
t = 1
while t <= tst:
	n = int(input())
	s = input()
	ls = []
	ls[:0] = s
	r = b = 0
	i = 0
	while i < len(ls):
		p = ord(ls[i])
		p -= 48
		if i % 2 == 0:
			if p % 2 == 1:
				r = 1
		elif p % 2 == 0:
			b = 1
		i += 1
	if n % 2 == 1:
		if r == 1:
			print(1)
		else:
			print(2)
	elif b == 1:
		print(2)
	else:
		print(1)
	t += 1


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	s = input()
	if n % 2 == 0:
		for i in s[1::2]:
			if i in '24680':
				print(2)
				break
		else:
			print(1)
	else:
		for i in s[::2]:
			if i in '13579':
				print(1)
				break
		else:
			print(2)
	return
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')
tests = int(input())
for i in range(tests):
	main()


for i in range(int(input())):
	n = int(input())
	a = [int(i) for i in input()][:n]
	v = 0
	if n % 2 == 1:
		v = 2
		for i in range(n):
			if i % 2 == 0 and a[i] % 2 == 1:
				v = 1
	else:
		v = 1
		for i in range(n):
			if i % 2 == 1 and a[i] % 2 == 0:
				v = 2
	print(v)


tt = int(input())
for _ in range(tt):
	(odd, even) = ([], [])
	n = int(input())
	num = int(input())
	a = list(str(num))
	for i in range(n):
		if i % 2 == 0:
			odd.append(a[i])
		else:
			even.append(a[i])
	even = list(map(int, even))
	odd = list(map(int, odd))
	if n % 2 == 0:
		if any((i % 2 == 0 for i in even)):
			print(2)
		else:
			print(1)
	elif any((i % 2 != 0 for i in odd)):
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	digit = int(input())
	if n == 1:
		if digit % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		val = str(digit)
		even = 0
		odd = 0
		if len(val) % 2 == 0:
			for j in range(1, len(val), 2):
				if int(val[j]) % 2 == 0:
					even += 1
				else:
					odd += 1
			if even:
				print(2)
			else:
				print(1)
		else:
			for j in range(0, len(val), 2):
				if int(val[j]) % 2 == 0:
					even += 1
				else:
					odd += 1
			if odd:
				print(1)
			else:
				print(2)


x = int(input())
for i in range(x):
	digit = int(input())
	number = []
	number[:] = input()
	RazeEven = 0
	RazeOdd = 0
	BreechEven = 0
	BreechOdd = 0
	RazeWin = True
	for n in range(0, len(number)):
		if (n + 1) % 2 != 0:
			if int(number[n]) % 2 == 0:
				RazeEven += 1
			else:
				RazeOdd += 1
		elif int(number[n]) % 2 == 0:
			BreechEven += 1
		else:
			BreechOdd += 1
	for num in range(digit):
		if RazeEven + RazeOdd + BreechEven + BreechOdd == 1:
			if RazeEven > 0:
				RazeWin = False
			if BreechEven > 0:
				RazeWin = False
		elif RazeEven > 0:
			RazeEven -= 1
		else:
			RazeOdd -= 1
		if RazeEven + RazeOdd + BreechEven + BreechOdd == 1:
			if RazeEven > 0:
				RazeWin = False
			if BreechEven > 0:
				RazeWin = False
		elif BreechOdd > 0:
			BreechOdd -= 1
		else:
			BreechEven -= 1
	if RazeWin:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(x) for x in input()]
	A = s[0::2]
	B = s[1::2]
	if n % 2 == 0:
		if any((x % 2 == 0 for x in B)):
			print(2)
		else:
			print(1)
	elif any((x % 2 == 1 for x in A)):
		print(1)
	else:
		print(2)


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	n = int(stdin.readline())
	a = list(stdin.readline().strip())
	(o, e) = ([], [])
	ch = 1
	for i in a:
		x = int(i)
		if ch:
			o.append(x)
			ch ^= 1
		else:
			e.append(x)
			ch ^= 1
	if n & 1:
		ans = 2
		for i in o:
			if i & 1:
				ans = 1
				break
	else:
		ans = 1
		for i in e:
			if i & 1 ^ 1:
				ans = 2
				break
	print(ans)


test = int(input())
for i in range(test):
	t = int(input())
	v = input()
	even = any([int(v[i]) % 2 == 0 for i in range(1, t, 2)])
	odd = any([int(v[i]) % 2 == 1 for i in range(0, t, 2)])
	if t % 2 == 0 and even or (t % 2 == 1 and (not odd)):
		print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	num = list(input())
	odd_pos = []
	even_pos = []
	for i in range(0, len(num), 2):
		odd_pos.append(int(num[i]))
		if i + 1 < len(num):
			even_pos.append(int(num[i + 1]))
	if len(num) % 2 != 0:
		for i in odd_pos:
			if i % 2 != 0:
				print('1')
				break
		else:
			print('2')
	else:
		for i in even_pos:
			if i % 2 == 0:
				print('2')
				break
		else:
			print('1')


testcases = int(input())
for testcase in range(testcases):
	n = int(input())
	strs = input()
	oddposeven = 0
	oddposodd = 0
	evenposeven = 0
	evenposodd = 0
	count = 0
	index = 1
	for i in strs:
		if index & 1:
			getint = int(i)
			if getint & 1:
				oddposodd += 1
			else:
				oddposeven += 1
		else:
			getint = int(i)
			if getint & 1:
				evenposodd += 1
			else:
				evenposeven += 1
		index += 1
	getmin = max(min(oddposeven, evenposodd) - 2, 0)
	getmin = max(min(oddposodd, evenposeven) - 2, 0)
	flag = 1
	while n != 1:
		if flag == 1 and oddposeven >= 1:
			oddposeven -= 1
			flag = 0
			n -= 1
		elif flag == 1:
			oddposodd -= 1
			flag = 0
			n -= 1
		elif flag == 0 and evenposodd >= 1:
			evenposodd -= 1
			flag = 1
			n -= 1
		else:
			flag = 1
			evenposeven -= 1
			n -= 1
	if oddposodd or evenposodd:
		print(1)
	else:
		print(2)


for t in range(int(input())):
	n = int(input())
	s = input()
	r = [int(i) for i in s[0::2]]
	b = [int(i) for i in s[1::2]]
	win = 0
	if n % 2 == 1:
		win = 2
		for i in r:
			if i % 2 == 1:
				win = 1
				break
	else:
		win = 1
		for i in b:
			if i % 2 == 0:
				win = 2
				break
	print(win)


t = int(input())
for z in range(t):
	n = int(input())
	l = input()
	if n % 2 == 0:
		check = False
		for i in range(1, n, 2):
			if int(l[i]) % 2 == 0:
				check = True
				break
		if check:
			print(2)
			continue
		else:
			print(1)
			continue
	else:
		check = False
		for i in range(0, n, 2):
			if int(l[i]) % 2 != 0:
				check = True
				break
		if check:
			print(1)
			continue
		else:
			print(2)
			continue


def solve():
	n = int(input())
	l = list(map(int, list(input().strip())))
	odd = l[0::2]
	even = l[1::2]
	if len(even) >= len(odd):
		if any((i % 2 == 0 for i in even)):
			print(2)
		else:
			print(1)
	elif any((i % 2 == 1 for i in odd)):
		print(1)
	else:
		print(2)
runs = int(input())
while runs > 0:
	solve()
	runs -= 1


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	if n == 1:
		k = int(s)
		if k % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 1:
		b = False
		for i in range(0, n, 2):
			p = int(s[i])
			if p % 2 == 1:
				b = True
		if b:
			print(1)
		else:
			print(2)
	else:
		o = False
		for i in range(1, n, 2):
			p = int(s[i])
			if p % 2 == 0:
				o = True
		if o:
			print(2)
		else:
			print(1)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	d = [int(j) % 2 for j in input()]
	first = [0, 0]
	second = [0, 0]
	for j in range(0, n, 2):
		first[d[j]] += 1
	for j in range(1, n, 2):
		second[d[j]] += 1
	if n % 2:
		if first[1]:
			print(1)
		else:
			print(2)
	elif second[0]:
		print(2)
	else:
		print(1)


def check(r, b):
	c = r['e'] + r['o'] + b['e'] + b['o']
	if c == 1:
		if b['e'] == 1 or r['e'] == 1:
			return 2
		else:
			return 1
	else:
		return False
t = int(input())
for _ in range(t):
	n = int(input())
	l = list((int(x) for x in str(input())))
	r = {'o': 0, 'e': 0}
	b = {'o': 0, 'e': 0}
	for i in range(0, n):
		if i % 2 != 0:
			if l[i] % 2 == 0:
				b['e'] += 1
			else:
				b['o'] += 1
		elif l[i] % 2 == 0:
			r['e'] += 1
		else:
			r['o'] += 1
	while True:
		res = check(r, b)
		if res != False:
			break
		if r['e'] != 0:
			r['e'] -= 1
		else:
			r['o'] -= 1
		res = check(r, b)
		if res != False:
			break
		if b['o'] != 0:
			b['o'] -= 1
		else:
			b['e'] -= 1
	print(res)


def ans(x):
	if n % 2:
		for i in range(0, n, 2):
			if int(x[i]) % 2:
				return 1
		return 2
	else:
		for i in range(1, n, 2):
			if int(x[i]) % 2 == 0:
				return 2
		return 1
t = int(input())
for _ in range(t):
	n = int(input())
	x = list(input())
	print(ans(x))


t = int(input())
for i in range(t):
	count = 0
	dig = int(input())
	n = input()
	if dig == 1:
		if int(n) % 2 == 0:
			print(2)
		if int(n) % 2 != 0:
			print(1)
	elif dig % 2 != 0 and dig != 1:
		for j in range(0, len(n), 2):
			if int(n[j]) % 2 == 0:
				count += 1
		if count <= dig // 2:
			print(1)
		else:
			print(2)
	elif dig % 2 == 0 and dig != 1:
		for j in range(1, len(n), 2):
			if int(n[j]) % 2 != 0:
				count += 1
		if count <= dig // 2 - 1:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	val = input()
	list1 = list(val)
	list2 = [int(list1[i]) for i in range(len(list1))]
	if len(list2) == 1:
		if list2[0] % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		i = 0
		evenJ = -1
		oddI = -1
		while i < len(list2):
			if list2[i] % 2 != 0:
				oddI = 1
			i += 2
		j = 1
		while j < len(list2):
			if list2[j] % 2 == 0:
				evenJ = 1
			j += 2
		if len(list2) % 2 == 0:
			if evenJ == 1:
				print(2)
			else:
				print(1)
		elif oddI == 1:
			print(1)
		else:
			print(2)


import sys

def input():
	return sys.stdin.readline()[:-1]

def getInt():
	return int(input())

def getIntIter():
	return map(int, input().split())

def getIntList():
	return list(getIntIter())

def flush():
	sys.stdout.flush()
for _ in range(getInt()):
	n = getInt()
	num = input()
	digits = []
	for x in range(n):
		digits.append(int(num[x]))
	if len(digits) % 2 == 0:
		breach = digits[1::2]
		flag = False
		for x in breach:
			if x % 2 == 0:
				flag = True
				break
		print(1 + flag)
	else:
		flag = True
		raze = digits[::2]
		for x in raze:
			if x % 2 == 1:
				flag = False
				break
		print(1 + flag)


def Find_Digits(n):
	x = str(n)
	raze = [0, 0]
	Breach = [0, 0]
	for i in range(len(x)):
		if i % 2 == 0:
			m = int(x[i])
			if m % 2 == 0:
				raze[0] += 1
			else:
				raze[1] += 1
		else:
			m = int(x[i])
			if m % 2 == 0:
				Breach[0] += 1
			else:
				Breach[1] += 1
	for i in range(raze[0] + Breach[0] + raze[1] + Breach[1] - 1):
		if i % 2 == 0:
			if raze[0] != 0:
				raze[0] -= 1
			else:
				raze[1] -= 1
		elif Breach[1] != 0:
			Breach[1] -= 1
		else:
			Breach[0] -= 1
	val1 = sum(raze)
	val2 = sum(Breach)
	if val1 != 0:
		if raze[0] != 0:
			print(2)
		else:
			print(1)
	if val2 != 0:
		if Breach[0] != 0:
			print(2)
		else:
			print(1)

def main():
	t = int(input())
	while t > 0:
		t -= 1
		k = int(input())
		n = int(input())
		Find_Digits(n)
main()


t = int(input())
while t:
	n = int(input())
	li = list(map(int, input()))
	saze = False
	breach = False
	for i in range(n):
		if i % 2 == 0:
			if li[i] % 2 == 1:
				breach = True
		if i % 2 == 1:
			if li[i] % 2 == 0:
				saze = True
	if n % 2 == 0:
		if saze == True:
			print(2)
		else:
			print(1)
	elif breach == True:
		print(1)
	else:
		print(2)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	if n % 2 == 0:
		isEven = False
		for i in range(1, n, 2):
			if int(a[i]) % 2 == 0:
				isEven = True
		if isEven:
			print(2)
		else:
			print(1)
	else:
		isOdd = False
		for i in range(0, n, 2):
			if int(a[i]) % 2 == 1:
				isOdd = True
		if isOdd:
			print(1)
		else:
			print(2)


T = int(input())
for _ in range(T):
	N = int(input())
	X = [int(a) % 2 for a in input()]
	A = X[::2]
	B = X[1::2]
	A1 = A.count(1)
	B0 = B.count(0)
	if N % 2 == 1:
		print(1 if A1 else 2)
	else:
		print(2 if B0 else 1)


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	lis = list(input().strip())
	ro = 0
	re = 0
	for i in range(0, n, 2):
		if int(lis[i]) % 2 == 0:
			re += 1
		else:
			ro += 1
	bo = 0
	be = 0
	for i in range(1, n, 2):
		if int(lis[i]) % 2 == 0:
			be += 1
		else:
			bo += 1
	if n % 2 == 0:
		if be > 0:
			print(2)
		else:
			print(1)
	elif ro > 0:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline
T = int(input())
for testcase in range(T):
	n = int(input())
	s = list(input())
	if n % 2 == 1:
		flag = False
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 1:
				flag = True
				break
		if flag:
			print(1)
		else:
			print(2)
	else:
		flag = False
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				flag = True
				break
		if flag:
			print(2)
		else:
			print(1)


for i in range(int(input())):
	n = int(input())
	a = input()
	r = []
	b = []
	c1 = 0
	c2 = 0
	for i in range(n):
		if i % 2 == 0:
			r.append(int(a[int(i)]))
		else:
			b.append(int(a[int(i)]))
	for i in r:
		if i % 2 != 0:
			c1 = 1
			break
	for i in b:
		if i % 2 == 0:
			c2 = 1
			break
	if len(r) > len(b):
		if c1 == 1:
			print('1')
		else:
			print('2')
	if len(r) == len(b):
		if c2 == 1:
			print('2')
		else:
			print('1')


T = int(input())
for t in range(T):
	o = [0, 0]
	n = int(input())
	s = input()
	result = 1
	if n % 2 == 0:
		for i in range(1, n, 2):
			o[int(s[i]) % 2] += 1
		if o[0] > 0:
			result = 2
	else:
		for i in range(0, n, 2):
			o[int(s[i]) % 2] += 1
		if o[1] == 0:
			result = 2
	print(result)


def x():
	N = int(input())
	for i in range(N):
		A = int(input())
		B = input()
		ans = []
		if A % 2 == 0:
			for j in range(1, A, 2):
				if int(B[j]) % 2 == 0:
					print(2)
					break
			else:
				print(1)
		else:
			for j in range(0, A, 2):
				if int(B[j]) % 2 == 1:
					print(1)
					break
			else:
				print(2)
x()


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = input()
	a = b = 0
	for i in range(n):
		if i & 1:
			a += not int(s[i]) & 1
		else:
			b += int(s[i]) & 1
	if n & 1 and b or (not n & 1 and (not a)):
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	a1 = input()
	a = [0] * n
	for i in range(n):
		a[i] = int(a1[i])
	(odd, even) = ([], [])
	for i in range(n):
		if i % 2 == 0:
			odd.append(a[i])
		else:
			even.append(a[i])
	(odd1_odd, odd1_even) = ([], [])
	for i in range(len(odd)):
		if odd[i] % 2 == 0:
			odd1_even.append(odd[i])
		else:
			odd1_odd.append(odd[i])
	ans1 = odd1_even + odd1_odd
	(even1_odd, even1_even) = ([], [])
	for i in range(len(even)):
		if even[i] % 2 == 0:
			even1_even.append(even[i])
		else:
			even1_odd.append(even[i])
	ans2 = even1_even + even1_odd
	ans = []
	c = 0
	if len(ans1) > len(ans2):
		ans = ans + ans1
		c = len(ans1) - len(ans2)
	else:
		ans = ans + ans2
		c = len(ans2) - len(ans1)
	if ans[-c] % 2 == 0:
		print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	if n == 1:
		if int(a[0]) % 2:
			print(1)
		else:
			print(2)
		continue
	if n % 2:
		ans = False
		for i in range(0, n, 2):
			if int(a[i]) % 2 == 1:
				ans = True
				break
		if ans:
			print(1)
		else:
			print(2)
	else:
		ans = False
		for i in range(1, n, 2):
			if int(a[i]) % 2 == 0:
				ans = True
				break
		if ans:
			print(2)
		else:
			print(1)


import sys
input = sys.stdin.readline

def read():
	N = int(input().strip())
	K = list(map(int, list(input().strip())))
	return (N, K)

def solve(N, K):
	if N % 2 == 1:
		for i in range(0, N, 2):
			if K[i] % 2 == 1:
				return 1
		return 2
	else:
		for i in range(1, N, 2):
			if K[i] % 2 == 0:
				return 2
		return 1
T = int(input().strip())
for t in range(T):
	inputs = read()
	print('%s' % solve(*inputs))


from collections import defaultdict

def whoWins(n, x):
	digits = list(map(int, list(str(x))))
	(odds, evens) = (defaultdict(int), defaultdict(int))
	for i in range(n):
		if i % 2 == 0:
			if digits[i] % 2 == 0:
				odds['even'] += 1
			else:
				odds['odd'] += 1
		elif digits[i] % 2 == 0:
			evens['even'] += 1
		else:
			evens['odd'] += 1
	if n % 2 == 0:
		if evens['even'] > 0:
			return 2
		else:
			return 1
	elif odds['odd'] > 0:
		return 1
	else:
		return 2
t = int(input())
for i in range(t):
	n = int(input())
	x = int(input())
	print(whoWins(n, x))


for _ in range(int(input())):
	d = int(input())
	s = input()
	f = 0
	if d & 1:
		for i in range(d):
			if i % 2 == 0 and int(s[i]) % 2 != 0:
				f = 1
				break
		if f == 1:
			print(1)
		else:
			print(2)
	else:
		for i in range(d):
			if i & 1 and int(s[i]) % 2 == 0:
				f = 1
				break
		if f == 1:
			print(2)
		else:
			print(1)


def solve(n, a):
	if n % 2 == 0:
		return 1 if all(((ord(a[i]) - ord('0')) % 2 == 1 for i in range(1, n, 2))) else 2
	else:
		return 1 if any(((ord(a[i]) - ord('0')) % 2 == 1 for i in range(0, n, 2))) else 2
tests = int(input())
for test in range(tests):
	n = int(input())
	a = input()
	print(solve(n, a))


for s in [*open(0)][2::2]:
	a = [int(x) % 2 for x in s[:-1]]
	k = len(a) % 2
	print(2 - (0 not in a[1::2], 1 in a[::2])[k])


T = int(input())
for _ in range(T):
	n = int(input())
	num = int(input())
	if n == 1:
		if num % 2 == 0:
			print(2)
		else:
			print(1)
	elif n == 2:
		if num % 2:
			print(1)
		else:
			print(2)
	elif n % 2 == 0:
		i = n
		f = 0
		while num > 0:
			x = num % 10
			if i % 2 == 0 and x % 2 == 0:
				f = 1
				break
			num //= 10
			i -= 1
		if f:
			print(2)
		else:
			print(1)
	else:
		i = n
		f = 0
		while num > 0:
			x = num % 10
			if i % 2 and x % 2:
				f = 1
				break
			num //= 10
			i -= 1
		if f:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input()]
	if len(a) % 2:
		c = 0
		for z in range(0, len(a), 2):
			if a[z] % 2:
				print(1)
				c = 1
				break
		if not c:
			print(2)
	else:
		c = 0
		for z in range(1, len(a), 2):
			if not a[z] % 2:
				print(2)
				c = 1
				break
		if not c:
			print(1)


from math import ceil
from sys import stdin, stdout, setrecursionlimit
from random import randint
for _ in range(int(input())):
	n = int(input())
	s = input()
	cnt = 0
	if n % 2 == 1:
		for i in range(0, n, 2):
			if int(s[i]) % 2 == 1:
				cnt += 1
		print(1 if cnt > 0 else 2)
	else:
		for i in range(1, n, 2):
			if int(s[i]) % 2 == 0:
				cnt += 1
		print(2 if cnt > 0 else 1)


t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	s = input()
	if n & 1:
		look = True
		for i in range(0, n, 2):
			if int(s[i]) & 1:
				look = False
				break
		if look:
			ans.append('2')
		else:
			ans.append('1')
	else:
		look = True
		for i in range(1, n, 2):
			if int(s[i]) & 1 == 0:
				look = False
				break
		if look:
			ans.append('1')
		else:
			ans.append('2')
print('\n'.join(ans))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	num = input()
	if n % 2 == 0:
		i = 1
		yes = False
		while i < n:
			if int(num[i]) % 2 == 0:
				yes = True
			i += 2
		if yes == True:
			print(2)
		else:
			print(1)
	else:
		i = 0
		yes = False
		while i < n:
			if int(num[i]) % 2 != 0:
				yes = True
			i += 2
		if yes == True:
			print(1)
		else:
			print(2)


for i in range(int(input())):
	n = int(input())
	s = input()
	g = True
	if n % 2 == 0:
		for j in s[1::2]:
			if int(j) % 2 == 0:
				print(2)
				g = False
				break
		if g == True:
			print(1)
	else:
		for j in s[::2]:
			if int(j) % 2 != 0:
				print(1)
				g = False
				break
		if g == True:
			print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	g = 0
	f = 0
	for i in range(n):
		k = int(s[i])
		if i % 2 == 0:
			if k % 2 != 0:
				f = 1
		elif k % 2 == 0:
			g = 1
	if n % 2 == 0:
		if g == 1:
			print(2)
		else:
			print(1)
	elif f == 1:
		print(1)
	else:
		print(2)


t = int(input())
while t:
	n = int(input())
	N = int(input())
	s = list(str(N))
	if len(s) == 1:
		if N % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		(lo, le) = ([], [])
		for i in range(len(s)):
			if i % 2 == 0:
				lo.append(s[i])
			else:
				le.append(s[i])
		(loeven_count, loodd_count) = (0, 0)
		(leeven_count, leodd_count) = (0, 0)
		for num in lo:
			if int(num) % 2 == 0:
				loeven_count += 1
			else:
				loodd_count += 1
		for num in le:
			if int(num) % 2 == 0:
				leeven_count += 1
			else:
				leodd_count += 1
		if len(s) % 2 == 0:
			if leeven_count != 0:
				print(2)
			else:
				print(1)
		elif loodd_count != 0:
			print(1)
		else:
			print(2)
	t = t - 1


import os
import heapq
import sys, threading
import math
import operator
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		ar = []
		s = int(input())
		n = int(input())
		while n:
			r = n % 10
			ar.append(r)
			n //= 10
		ar = ar[::-1]
		ans = [[0, 0], [0, 0]]
		for i in range(len(ar)):
			if i % 2 == 0:
				ans[0][ar[i] % 2] += 1
			else:
				ans[1][ar[i] % 2] += 1
		if len(ar) % 2 == 1 and ans[0][1] > 0:
			print(1)
		elif len(ar) % 2 == 1 and ans[0][1] == 0:
			print(2)
		elif ans[1][1] > 0 and ans[1][0] == 0:
			print(1)
		else:
			print(2)
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()


t = int(input())
for _ in range(t):
	total = int(input())
	nums = [int(n) for n in input()]
	if total == 1:
		winner = 1 if nums[0] % 2 == 1 else 2
	else:
		oe = [0, 0]
		target = (total + 1) % 2
		for (i, n) in enumerate(nums):
			if i % 2 == target:
				oe[n % 2] += 1
		if target == 1:
			winner = 2 if oe[0] > 0 else 1
		else:
			winner = 1 if oe[1] > 0 else 2
	print(winner)


t = int(input())
for i in range(t):
	n = int(input())
	number = int(input())
	j = 0 if n % 2 == 0 else 1
	odd = even = flag = 0
	while number > 0:
		x = number % 10
		if j % 2 == x % 2 == 0:
			even += 1
		elif j % 2 == x % 2 == 1:
			odd += 1
		if n % 2 == 1 and odd > 0:
			print('1')
			flag = 1
			break
		elif n % 2 == 0 and even > 0:
			print('2')
			flag = 1
			break
		j += 1
		number //= 10
	if flag == 0:
		if n % 2 == 0 and even == 0:
			print('1')
		elif n % 2 == 1 and odd == 0:
			print('2')


def fun(l, n):

	def iseve(k):
		if k % 2 == 0:
			return 1
		else:
			return 0
	if not iseve(l):
		for dig in str(n)[::2]:
			if not iseve(int(dig)):
				return 1
		return 2
	else:
		for dig in str(n)[1::2]:
			if iseve(int(dig)):
				return 2
		return 1
n = int(input())
l = []
no = []
for i in range(n):
	l.append(int(input()))
	no.append(int(input()))
for i in range(n):
	print(fun(l[i], no[i]))


from enum import *
from copy import *
from sys import *
from collections import *
from itertools import *
from functools import *
from math import *

def l2i(fr=None):
	return map_type_to_fr(int, fr)[0]

def i2i(fr=None):
	return l2i(fr)

def dbg(*args):
	print(*args, file=stderr)

def dbv(var_name):
	print(f'{var_name} = {eval(var_name)}', file=stderr)

def map_type_to_fr(t, fr):
	global GETLINE_OFFSET
	if fr is None:
		if RUNNING_ON_MY_PC:
			fr = TEST_INP[GETLINE_OFFSET].split()
			GETLINE_OFFSET += 1
		else:
			fr = input().split()
	return list(map(t, fr))

def mis(fr=None):
	return map_type_to_fr(int, fr)

def mbs(fr=None):
	return map_type_to_fr(bool, fr)

def gs(fr=None):
	return map_type_to_fr(str, fr)[0]
import os
import sysconfig
RUNNING_ON_MY_PC = os.name == 'nt' and platform == 'win32' and (sysconfig.get_platform() == 'win-amd64')
GETLINE_OFFSET = 0
TEST_INP = '4\n1\n2\n1\n3\n3\n102\n4\n2069\n\n'.split('\n')
t = i2i()
for _ in range(t):
	n = i2i()
	if n == 1:
		if i2i() % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	a = [0, 0]
	for (i, d) in enumerate(gs()):
		p = (i + 1) % 2
		d = int(d)
		if d % 2 == p:
			a[p] += 1
	if n % 2 == 0:
		if a[0] >= 1:
			print(2)
			continue
		else:
			print(1)
			continue
	elif a[1] >= 1:
		print(1)
		continue
	else:
		print(2)
		continue


import os
os_input = os.read(0, int(10000000.0)).split()
os_input_pos = -1
answer_list = []

def read_s():
	global os_input_pos
	os_input_pos += 1
	return os_input[os_input_pos].decode()

def read_i():
	return int(read_s())

def write_s(v):
	answer_list.append(v)

def write_i(v):
	write_s(str(v))

def print_ans():
	os.write(1, '\n'.join(answer_list).encode())
	os.write(1, '\n'.encode())
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
			else:
				stack.pop()
				if not stack:
					break
				to = stack[-1].send(to)
		return to
	return wrapped_func
T = read_i()
while T:
	T -= 1
	n = read_i()
	s = read_s()
	odd = [int(x) % 2 for x in s[::2]]
	even = [int(x) % 2 for x in s[1::2]]
	if n % 2 == 0:
		write_i(1 if even.count(0) == 0 else 2)
	else:
		write_i(1 if odd.count(1) != 0 else 2)
print_ans()


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		l = list(input())
		(odd, eve) = ([], [])
		for x in range(n):
			if x & 1 == 1:
				eve.append(int(l[x]))
			else:
				odd.append(int(l[x]))
		if n & 1 == 1:
			flag = 0
			for x in odd:
				if x & 1 == 1:
					flag = 1
					break
			if flag == 1:
				print(1)
			else:
				print(2)
		else:
			flag = 0
			for x in eve:
				if x & 1 != 1:
					flag = 1
					break
			if flag == 1:
				print(2)
			else:
				print(1)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


n = int(input())
for i in range(0, n):
	m = int(input())
	a = input()
	odd = []
	even = []
	for j in range(0, m):
		if j % 2 == 0:
			odd.append(int(a[j]))
		else:
			even.append(int(a[j]))
	if m % 2 == 0:
		bl = False
		for o in range(0, len(even)):
			if even[o] % 2 == 0:
				bl = True
				break
		if bl:
			print('2')
		else:
			print('1')
	else:
		bl = False
		for o in range(0, len(odd)):
			if odd[o] % 2 == 1:
				bl = True
				break
		if bl:
			print('1')
		else:
			print('2')


import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 998244353

def main():
	ans = ''
	for _ in range(int(input())):
		n = int(input())
		s = int(input())
		t = str(s)
		if n % 2:
			fl = 0
			for i in range(0, n, 2):
				fl |= int(t[i]) % 2
			ans += str([2, 1][fl]) + '\n'
		else:
			fl = 0
			for i in range(1, n, 2):
				fl |= int(t[i]) % 2 == 0
			ans += str([1, 2][fl]) + '\n'
	print(ans)
main()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		n = int(input())
		nums = input()
		got = False
		if n % 2:
			for i in range(n // 2 + 1):
				if int(nums[i * 2]) % 2:
					got = True
					break
			if not got:
				ans = 2
			else:
				ans = 1
		else:
			for i in range(n // 2):
				if int(nums[i * 2 + 1]) % 2 == 0:
					got = True
					break
			if not got:
				ans = 1
			else:
				ans = 2
		yield ans
t = int(input())
ans = gift()
print(*ans, sep='\n')


import sys

def f(x):
	return int(x) % 2
for i in range(0, int(sys.stdin.readline())):
	l = sys.stdin.readline()
	num = list(sys.stdin.readline())
	num.pop(len(num) - 1)
	oel = list(map(f, num))
	rwins = False
	if len(oel) % 2 == 0:
		rwins = not 0 in oel[1::2]
	else:
		rwins = 1 in oel[::2]
	if rwins:
		sys.stdout.write('1\n')
	else:
		sys.stdout.write('2\n')


for i in range(int(input())):
	n = int(input())
	num = input()
	r = []
	b = []
	for j in range(0, len(num)):
		if j % 2 != 0:
			b.append(int(num[j]))
		else:
			r.append(int(num[j]))
	if len(r) == len(b):
		win = 1
		for j in b:
			if j % 2 == 0:
				win = 2
				break
	else:
		win = 2
		for j in r:
			if j % 2 != 0:
				win = 1
				break
	print(win)


import os
import sys
from io import BytesIO, IOBase
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')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = [int(k) for k in input()]
	ans = 1 if n % 2 == 0 else 2
	for i in range(n):
		if n % 2 == 0 and i % 2 and (not a[i] % 2):
			ans = 2
			break
		if n % 2 == 1 and (not i % 2) and a[i] % 2:
			ans = 1
			break
	print(ans)


t = int(input())
for j in range(0, t):
	n = int(input())
	m = input()
	g = 0
	if n % 2 == 0:
		for l in range(1, n, 2):
			if int(m[l]) % 2 == 0:
				print(2)
				g = -1
				break
		if g == 0:
			print(1)
	else:
		for l in range(0, n, 2):
			if int(m[l]) % 2 != 0:
				print(1)
				g = -1
				break
		if g == 0:
			print(2)


noMatches = int(input())
while noMatches:
	n = int(input())
	nums = input()
	nums = [int(i) for i in nums]
	evens = nums[::2]
	odds = nums[1::2]
	evens.sort(key=lambda x: x & 1 == 1)
	odds.sort(key=lambda x: x & 1 == 0)
	if n & 1:
		cond = evens[-1] & 1
	else:
		cond = odds[-1] & 1 == 1
	print('1' if cond else '2')
	noMatches -= 1


import sys
mod = 1000000007

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

def solution(digit, n):
	if n == 1:
		if int(digit) & 1:
			print(1)
			return
		else:
			print(2)
			return
	oo = 0
	for i in range(0, n, 2):
		if int(digit[i]) & 1:
			oo += 1
	ee = 0
	for i in range(1, n, 2):
		if int(digit[i]) & 1 == 0:
			ee += 1
	if n & 1:
		if oo != 0:
			print(1)
			return
		else:
			print(2)
			return
	elif ee != 0:
		print(2)
		return
	else:
		print(1)
		return

def main():
	t = int(input().strip())
	for _ in range(t):
		n = int(input())
		digit = input()
		solution(digit, n)
main()


for _ in range(int(input())):
	n = int(input())
	num = input()
	if n % 2 != 0:
		for i in range(0, n, 2):
			if int(num[i]) % 2 != 0:
				res = 1
				break
			else:
				res = 2
	elif n % 2 == 0:
		for i in range(1, n, 2):
			if int(num[i]) % 2 == 0:
				res = 2
				break
			else:
				res = 1
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	s = list(s)
	B = 0
	R = 0
	for j in range(n):
		if (j + 1) % 2 == 0 and int(s[j]) % 2 == 0:
			B += 1
		elif (j + 1) % 2 != 0 and int(s[j]) % 2 != 0:
			R += 1
	if n % 2 == 0:
		if B > 0:
			print(2)
		else:
			print(1)
	elif R > 0:
		print(1)
	else:
		print(2)


import sys, io, os, time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for ii in range(int(input())):
	n = int(input())
	arr = input()
	raze = []
	breach = []
	for i in range(0, n, 2):
		raze.append(int(arr[i]))
	for i in range(1, n, 2):
		breach.append(int(arr[i]))
	raze.sort(key=lambda x: x % 2, reverse=True)
	breach.sort(key=lambda x: x % 2)
	f = 0
	while len(raze) + len(breach) != 1:
		if not f:
			raze.pop()
		else:
			breach.pop()
		f = not f
	if len(raze):
		if raze[0] % 2 == 1:
			print(1)
		else:
			print(2)
	elif breach[0] % 2 == 0:
		print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	num = int(input())
	num = str(num)
	num = list(num)
	r = 0
	b = 0
	for i in range(len(num)):
		if i % 2 == 0:
			if int(num[i]) % 2 == 1:
				r = r + 1
		elif int(num[i]) % 2 == 0:
			b = b + 1
	if n & 1:
		if r == 0:
			print(2)
		else:
			print(1)
	elif b == 0:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	input()
	n = [c for c in input()]
	if len(n) % 2 == 0:
		even = False
		for i in range(1, len(n), 2):
			if int(n[i]) % 2 == 0:
				even = True
		if even:
			print('2')
		else:
			print('1')
	else:
		odd = False
		for i in range(0, len(n), 2):
			if int(n[i]) % 2 == 1:
				odd = True
		if odd:
			print('1')
		else:
			print('2')


x = int(input())
ansl = []
for i in range(x):
	l = []
	r = []
	b = []
	odd = 0
	even = 0
	n = int(input())
	dig = int(input())
	if n == 1:
		if dig % 2 == 1:
			ansl.append(1)
		else:
			ansl.append(2)
	else:
		for i in str(dig):
			l.append(int(i))
		for i in range(1, len(l) + 1):
			if i % 2 == 1:
				r.append(l[i - 1])
			else:
				b.append(l[i - 1])
		for i in r:
			if i % 2 == 1:
				odd += 1
		for i in b:
			if i % 2 == 0:
				even += 1
		if len(r) > len(b):
			if odd > 0:
				ansl.append(1)
			else:
				ansl.append(2)
		elif even > 0:
			ansl.append(2)
		else:
			ansl.append(1)
for i in ansl:
	print(i)


t = int(input())
for test in range(t):
	n = int(input())
	a = list(input())
	odd = 0
	even = 0
	if n == 1:
		if int(a[0]) % 2 == 0:
			print(2)
			continue
		else:
			print(1)
			continue
	cntodd = 0
	cnteven = 0
	for x in a:
		if int(x) % 2 == 0:
			cnteven += 1
		else:
			cntodd += 1
	for i in range(0, n, 2):
		if int(a[i]) % 2 == 0:
			even += 1
	for i in range(1, n, 2):
		if int(a[i]) % 2 == 1:
			odd += 1
	turn = 0
	while True:
		if turn % 2 == 0:
			if even > 0:
				cnteven -= 1
				even -= 1
			else:
				cntodd -= 1
		elif odd > 0:
			cntodd -= 1
			odd -= 1
		else:
			cnteven -= 1
		if cntodd == 0:
			print(2)
			break
		elif cnteven == 0:
			print(1)
			break
		turn += 1


def who_wins(numstr, n):
	potential_winner = (int(numstr) + 1) % 2
	if n != 1:
		potential_winner = n % 2
		for i in range((potential_winner + 1) % 2, n, 2):
			if int(numstr[i]) % 2 == potential_winner:
				potential_winner = (potential_winner + 1) % 2
				break
	return [1, 2][potential_winner]
t = int(input())
for i in range(t):
	n = int(input())
	numstr = input()
	print(who_wins(numstr, n))


t = int(input())
buf = []
for _ in range(t):
	d = int(input())
	n = input()
	(r0, r1) = (0, 0)
	(b0, b1) = (0, 0)
	for i in range(d):
		k = int(n[i])
		if i % 2 == 0:
			if k % 2 == 0:
				r0 += 1
			else:
				r1 += 1
		elif k % 2 == 0:
			b0 += 1
		else:
			b1 += 1
	if r0 + b0 == 0:
		buf.append(1)
		continue
	elif r1 + b1 == 0:
		buf.append(2)
		continue
	if d % 2 == 1:
		if r1 > 0:
			buf.append(1)
		else:
			buf.append(2)
	elif b0 > 0:
		buf.append(2)
	else:
		buf.append(1)
print('\n'.join(map(str, buf)))


def jo(a):
	if a % 2 == 0:
		return 0
	else:
		return 1
a = input()
r = []
for i in range(int(a)):
	m = input()
	m = int(m)
	n = input()
	t = 0
	if jo(m) == 0:
		for k in range(int(m / 2)):
			if jo(int(n[k * 2 + 1])) == 0:
				r.append(2)
				t = 1
				break
		if t == 0:
			r.append(1)
	else:
		for k in range(int((m + 1) / 2)):
			if jo(int(n[k * 2])) == 1:
				r.append(1)
				t = 1
				break
		if t == 0:
			r.append(2)
for i in range(int(a)):
	print(r[i])


for _ in range(int(input())):
	n = int(input())
	s = input()
	r = []
	for i in s[0::2]:
		r.append(int(i))
	b = []
	for j in s[1::2]:
		b.append(int(j))
	win = 0
	if n % 2 == 1:
		win = 2
		for i in r:
			if i % 2 == 1:
				win = 1
				break
	else:
		win = 1
		for i in b:
			if i % 2 == 0:
				win = 2
				break
	print(win)


for i in range(int(input())):
	n = int(input())
	value = input()
	if n & 1 == 1:
		print(1) if any((int(value[i]) & 1 for i in range(0, n, 2))) else print(2)
	else:
		print(2) if any((not int(value[i]) & 1 for i in range(1, n, 2))) else print(1)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	x = input()
	if n % 2 == 0:
		print([1, 2][any(((ord(x[i]) - 48) % 2 == 0 for i in range(1, len(x), 2)))])
	else:
		print([2, 1][any(((ord(x[i]) - 48) % 2 == 1 for i in range(0, len(x), 2)))])


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(input())
	a = list(map(int, a))
	turn = 0
	changed = 0
	while True:
		lastval = -1
		chg = -1
		if changed == n - 1:
			break
		for i in range(turn, n, 2):
			if a[i] != -1:
				lastval = i
			if a[i] != -1 and a[i] % 2 == turn:
				changed += 1
				a[i] = -1
				chg = i
				break
		if chg == -1 and lastval != -1:
			changed += 1
			a[lastval] = -1
		turn = 1 - turn
	for i in range(n):
		if a[i] != -1:
			print(2 - a[i] % 2)
			break


ans = []
for _ in range(int(input())):
	n = int(input())
	num = input()
	R = 0
	B = 0
	for i in range(1, n + 1):
		if i % 2 == 1:
			if int(num[i - 1]) % 2 == 1:
				R += 1
		elif int(num[i - 1]) % 2 == 0:
			B += 1
	if n % 2 == 0:
		ans.append(2 if B != 0 else 1)
	else:
		ans.append(1 if R != 0 else 2)
print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	(o, e) = (False, False)
	for i in range(n):
		if i % 2 == 0 and int(s[i]) % 2:
			o = True
		if i % 2 and int(s[i]) % 2 == 0:
			e = True
	if n % 2:
		print(1 if o else 2)
	else:
		print(2 if e else 1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	(r, b) = (0, 0)
	if n % 2 != 0:
		r = n // 2
		b = n // 2
	else:
		r = n // 2
		b = r - 1
	(re, ro) = (0, 0)
	(be, bo) = (0, 0)
	for i in range(len(s)):
		if i % 2 == 0:
			if int(s[i]) % 2 == 0:
				re += 1
			else:
				ro += 1
		elif int(s[i]) % 2 == 0:
			be += 1
		else:
			bo += 1
	if n % 2 == 0:
		if bo > b:
			print(1)
		else:
			print(2)
	elif re > r:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	digits = int(input())
	n = input()
	odd_pos = n[::2]
	odd_pos_even_dig = 0
	odd_pos_odd_dig = 0
	even_pos = n[1::2]
	even_pos_odd_dig = 0
	even_pos_even_dig = 0
	for i in odd_pos:
		i = int(i)
		if i % 2 == 0:
			odd_pos_even_dig += 1
		else:
			odd_pos_odd_dig += 1
	for i in even_pos:
		i = int(i)
		if i % 2 == 0:
			even_pos_even_dig += 1
		else:
			even_pos_odd_dig += 1
	if digits % 2 == 0:
		if even_pos_even_dig >= 1:
			print(2)
		else:
			print(1)
	elif odd_pos_odd_dig >= 1:
		print(1)
	else:
		print(2)


for t in range(int(input())):
	(m, n) = (int(input()), str(input()))
	if m & 1:
		flag = int(0)
		for i in range(0, m, 2):
			k = int(n[i])
			if k & 1:
				flag = 1
		print('1' if flag else '2')
	else:
		flag = int(0)
		for i in range(1, m, 2):
			k = int(n[i])
			if k & 1:
				flag += 1
		print('1' if flag == m / 2 else '2')


for _ in range(int(input())):
	n = int(input())
	num = int(input())
	if n == 1:
		if num & 1:
			print(1)
		else:
			print(2)
		continue
	num = str(num)
	num = list(num)
	num = [int(x) for x in num]
	ce = 0
	co = 0
	f1 = 0
	f2 = 0
	for i in range(n):
		if f1 == -1 and f2 == -1:
			break
		if i & 1:
			if num[i] % 2 == 0:
				ce += 1
				f1 = -1
		elif num[i] & 1:
			co += 1
			f2 = -1
	if n & 1:
		if f2 == -1:
			print(1)
		else:
			print(2)
	elif f1 == -1:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	num = input()
	raze = breach = 0
	for i in range(0, n, 2):
		if int(num[i]) % 2 != 0:
			raze += 1
			break
	for i in range(1, n, 2):
		if int(num[i]) % 2 == 0:
			breach += 1
			break
	if n % 2 == 0 and breach == 0:
		print(1)
	elif n % 2 == 0 and breach == 1:
		print(2)
	elif n % 2 != 0 and raze == 0:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	o = 0
	e = 0
	for (i, j) in enumerate(s):
		if int(j) % 2 == 0 and (i + 1) % 2 == 0:
			e += 1
		elif int(j) % 2 == 1 and (i + 1) % 2 == 1:
			o += 1
	if n % 2 == 0:
		if e >= 1:
			print(2)
		else:
			print(1)
	elif o >= 1:
		print(1)
	else:
		print(2)


for i in range(int(input())):
	n = int(input())
	a = input()
	ans = 1
	(b1, b2) = (False, False)
	for j in range(1 if n % 2 == 0 else 0, n, 2):
		if n % 2 == 0:
			if int(a[j]) % 2 == 0:
				ans = 2
				break
			elif j >= n - 1:
				b1 = True
		elif int(a[j]) % 2 == 1:
			ans = 1
			break
		elif j >= n - 1:
			b2 = True
	if b1:
		ans = 1
	elif b2:
		ans = 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	s = input().strip()
	s1 = []
	for c in s:
		s1.append(int(c))
	if n % 2 == 1:
		flag = 0
		for i in range(0, n, 2):
			if s1[i] % 2 == 1:
				flag = 1
		if flag == 1:
			print(1)
		else:
			print(2)
	else:
		flag = 0
		for i in range(1, n, 2):
			if s1[i] % 2 == 0:
				flag = 1
		if flag == 1:
			print(2)
		else:
			print(1)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c for j in range(b)] for i in range(a)]

def list3d(a, b, c, d):
	return [[[d for k in range(c)] for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** (-10)
for _ in range(INT()):
	N = INT()
	S = list(map(int, input()))
	cnt = list2d(2, 2, 0)
	for i in range(N):
		cnt[i & 1][S[i] & 1] += 1
	for i in range(N - 1):
		if i % 2 == 0:
			if cnt[i & 1][0]:
				cnt[i & 1][0] -= 1
			else:
				cnt[i & 1][1] -= 1
		elif cnt[i & 1][1]:
			cnt[i & 1][1] -= 1
		else:
			cnt[i & 1][0] -= 1
	if cnt[0][1] or cnt[1][1]:
		print(1)
	else:
		print(2)


for pratyush in range(int(input())):
	n = int(input())
	(s, r, b, j) = (input(), 0, 0, 0)
	while j < n:
		if int(s[j]) % 2 == 1:
			r += 1
		j += 2
	j = 1
	while j < n:
		if int(s[j]) % 2 == 0:
			b += 1
		j += 2
	if n % 2 == 1:
		if r > 0:
			print(1, end='\n')
		else:
			print(2, end='\n')
	elif b > 0:
		print(2, end='\n')
	else:
		print(1, end='\n')


a = '13579'
b = '02468'
for t in range(int(input())):
	n = int(input())
	c = input()
	if n % 2:
		ans = 2
		for i in range(0, n, 2):
			if c[i] in a:
				ans = 1
				break
	else:
		ans = 1
		for i in range(1, n, 2):
			if c[i] in b:
				ans = 2
				break
	print(ans)


n = int(input())
for i in range(n):
	k = int(input())
	p = int(input())
	q = p
	a = []
	b = []
	while q > 0:
		c = q % 10
		q = q // 10
		a.append(c)
		if q > 0:
			c = q % 10
			q = q // 10
			b.append(c)
	if len(a) > len(b):
		for i in a:
			if i % 2 != 0:
				print(1)
				break
		else:
			print(2)
	else:
		for i in a:
			if i % 2 == 0:
				print(2)
				break
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	d = str(input())
	if n == 1:
		if int(d) % 2 == 0:
			print(2)
		else:
			print(1)
		continue
	Raze = []
	Breach = []
	m_r = []
	m_b = []
	for i in range(n):
		if i % 2 == 0:
			Raze.append(int(d[i]))
			if int(d[i]) % 2 == 0:
				m_r.append(0)
			else:
				m_r.append(1)
		else:
			Breach.append(int(d[i]))
			if int(d[i]) % 2 == 0:
				m_b.append(0)
			else:
				m_b.append(1)
	b = m_b.count(0)
	r = m_r.count(1)
	if b > 0 and n % 2 == 0:
		print(2)
	elif r == 0 and b == 0:
		if n % 2 == 1:
			print(2)
		else:
			print(1)
	elif r == 0 and n % 2 == 1:
		print(2)
	else:
		print(1)


t = int(input())
nums = []
c = []

def solve(num, n):
	c1 = False
	c2 = False
	b = str(num)
	for i in range(n):
		if i % 2 == 0:
			c1 = c1 or (int(b[i]) - 0) % 2 == 1
		if i % 2 == 1:
			c2 = c2 or (int(b[i]) - 0) % 2 == 0
	if n % 2 == 0:
		if c2:
			return 2
		else:
			return 1
	elif c1:
		return 1
	else:
		return 2
for i in range(t):
	n = int(input())
	c.append(n)
	x = int(input())
	nums.append(x)
for i in range(t):
	print(solve(nums[i], c[i]))


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	if len(s) == 1:
		if int(s) % 2 == 0:
			print(2)
		else:
			print(1)
	elif len(s) % 2 == 0:
		f1 = False
		for i in range(1, n, 2):
			p = int(s[i])
			if p % 2 == 0:
				f1 = True
				break
		if f1 == True:
			print(2)
		else:
			print(1)
	else:
		f2 = False
		for i in range(0, n, 2):
			p = int(s[i])
			if p % 2 == 1:
				f2 = True
				break
		if f2 == True:
			print(1)
		else:
			print(2)
	t -= 1


numLines = int(input(''))
digits = []
for i in range(0, numLines):
	n = int(input(''))
	digit = input('')
	digits.append(digit)
for num in digits:
	evenPos = []
	oddPos = []
	lastOddPos = True
	for i in range(0, len(num)):
		if (i + 1) % 2 == 0:
			evenPos.append(int(num[i]))
		else:
			oddPos.append(int(num[i]))
	if len(num) % 2 == 0:
		lastOddPos = False
	if lastOddPos is True:
		oddValueFound = False
		for n in oddPos:
			if n % 2 != 0:
				oddValueFound = True
				print('1')
				break
		if oddValueFound is False:
			print('2')
	else:
		evenValueFound = False
		for n in evenPos:
			if n % 2 == 0:
				evenValueFound = True
				print('2')
				break
		if evenValueFound is False:
			print('1')


def solve(n, k):
	p = str(k)
	if len(p) == 1:
		if k % 2 == 0:
			return 2
		else:
			return 1
	r_even = 0
	r_odd = 0
	b_even = 0
	b_odd = 0
	for i in range(n):
		if i % 2 == 0:
			if int(p[i]) % 2 == 0:
				r_even += 1
			else:
				r_odd += 1
		elif int(p[i]) % 2 == 0:
			b_even += 1
		else:
			b_odd += 1
	start = 1
	while n > 1:
		if start == 1:
			if r_even > 0:
				r_even -= 1
			else:
				r_odd -= 1
			start = 0
		else:
			if b_odd > 0:
				b_odd -= 1
			else:
				b_even -= 1
			start = 1
		n -= 1
	if r_even or b_even:
		return '2'
	else:
		return '1'
t = int(input())
while t:
	n = int(input())
	k = int(input())
	print(solve(n, k))
	t -= 1


matches = int(input())
res = []
for match in range(matches):
	lenNumber = int(input())
	theNumber = input()
	digits = [int(x) for x in theNumber]
	oposdigits = []
	eposdigits = []
	for i in range(0, lenNumber, 2):
		oposdigits.append(digits[i])
	for i in range(1, lenNumber, 2):
		eposdigits.append(digits[i])
	if lenNumber % 2 == 0:
		for i in range(len(eposdigits)):
			if eposdigits[i] % 2 == 0:
				res.append(2)
				break
			elif i == len(eposdigits) - 1:
				res.append(1)
			else:
				continue
	else:
		for i in range(len(oposdigits)):
			if oposdigits[i] % 2 != 0:
				res.append(1)
				break
			elif i == len(oposdigits) - 1:
				res.append(2)
			else:
				continue
for i in res:
	print(i)


for i in range(int(input())):
	n = int(input())
	k = list(map(int, list(input())))
	list1 = []
	list2 = []
	for x in range(len(k)):
		if x % 2 == 0 and k[x] % 2 == 1:
			list1.append((k[x], 1))
		elif x % 2 == 0 and k[x] % 2 == 0:
			list1.append((k[x], 0))
		elif k[x] % 2 == 1:
			list2.append((k[x], 0))
		else:
			list2.append((k[x], 1))
	list1.sort(key=lambda x: x[1])
	list2.sort(key=lambda x: x[1])
	for g in range(n - 1):
		if g % 2 == 0 and len(list1) != 0:
			del list1[0]
		elif len(list2) != 0 and g % 2 != 0:
			del list2[0]
	if len(list1) == 0:
		if list2[0][0] % 2 == 0:
			print(2)
		else:
			print(1)
	elif list1[0][0] % 2 == 0:
		print(2)
	else:
		print(1)


for i in range(int(input())):
	no = int(input())
	n = input()
	odd_p_odd = 0
	odd_p_even = 0
	even_p_odd = 0
	even_p_even = 0
	for i in range(0, len(n), 2):
		if int(n[i]) % 2 == 0:
			odd_p_even += 1
		else:
			odd_p_odd += 1
	for j in range(1, len(n), 2):
		if int(n[j]) % 2 == 0:
			even_p_even += 1
		else:
			even_p_odd += 1
	if no % 2 == 0:
		if even_p_even >= 1:
			print('2')
		else:
			print('1')
	elif odd_p_odd >= 1:
		print('1')
	else:
		print('2')


from __future__ import division, print_function
import os
import sys
from difflib import SequenceMatcher
from io import BytesIO, IOBase
from collections import Counter, deque
from heapq import heapify, heappush, heappop
from math import gcd, ceil, sqrt, log2, log
from itertools import accumulate, repeat, permutations, compress
from operator import itemgetter
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def arp(arr):
	return ' '.join([str(i) for i in arr])
for _ in range(int(input())):
	n = int(input())
	s = input()
	arr = []
	for i in range(n):
		arr.append(int(s[i]))
	razeodd = 0
	razeeven = 0
	breachodd = 0
	breacheven = 0
	for i in range(n):
		if i + 1 & 1:
			if arr[i] & 1:
				razeodd += 1
			else:
				razeeven += 1
		elif arr[i] & 1:
			breachodd += 1
		else:
			breacheven += 1
	if n & 1:
		if razeodd >= 1:
			print(1)
		else:
			print(2)
	elif breacheven >= 1:
		print(2)
	else:
		print(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')

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')


from sys import stdin, stdout
from math import gcd, log2, log10, floor, ceil
import math
from collections import defaultdict, OrderedDict
from bisect import bisect_left
for i in range(int(input())):
	n = int(input())
	m = list(input())
	even = 0
	odd = 0
	if n % 2 == 1:
		for i in range(len(m)):
			if int(m[i]) % 2 == 1 and i % 2 == 0:
				odd += 1
		if odd >= 1:
			winner = 1
		else:
			winner = 2
	if n % 2 == 0:
		for i in range(len(m)):
			if int(m[i]) % 2 == 0 and i % 2 == 1:
				even += 1
		if even >= 1:
			winner = 2
		else:
			winner = 1
	print(winner)


for _ in range(int(input())):
	n = int(input())
	num = input().strip()
	if n % 2 == 0:
		ans = 1
		for i in range(1, n, 2):
			if int(num[i]) % 2 == 0:
				ans = 2
				break
	else:
		ans = 2
		for i in range(0, n, 2):
			if int(num[i]) % 2 != 0:
				ans = 1
				break
	print(ans)


for T in range(int(input())):
	n = int(input())
	string = input()
	breach = 0
	raze = 0
	for i in range(len(string)):
		if (i + 1) % 2 == 0 and int(string[i]) % 2 == 0:
			breach += 1
		if (i + 1) % 2 != 0 and int(string[i]) % 2 != 0:
			raze += 1
	if len(string) % 2 == 0:
		if breach >= 1:
			ans = 2
		else:
			ans = 1
	if len(string) % 2 != 0:
		if raze >= 1:
			ans = 1
		else:
			ans = 2
	print(ans)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	n = int(input())
	a = input()
	if n % 2 == 0:
		breachWins = False
		for i in range(1, n, 2):
			if a[i] % 2 == 0:
				breachWins = True
				break
		if breachWins:
			print(2)
		else:
			print(1)
	else:
		razeWins = False
		for i in range(0, n, 2):
			if a[i] % 2 != 0:
				razeWins = True
				break
		if razeWins:
			print(1)
		else:
			print(2)


import math
t = int(input())
for w in range(t):
	n = int(input())
	s = list(input())
	(c1, c2) = (0, 0)
	if n % 2 == 0:
		(c3, c4) = (n // 2, n // 2)
	else:
		(c3, c4) = (n // 2 + 1, n // 2)
	for i in range(n):
		if (i + 1) % 2 == 1 and int(s[i]) % 2 == 0:
			c1 += 1
		elif (i + 1) % 2 == 0 and int(s[i]) % 2 == 1:
			c2 += 1
	if n % 2 == 0:
		if c2 < c4:
			print(2)
		else:
			print(1)
	elif c1 < c3:
		print(1)
	else:
		print(2)


def fu(a, s, e, sta):
	for i in range(s, e, 2):
		if sta == 0:
			if int(a[i]) % 2 == 1:
				return True
		elif int(a[i]) % 2 == 0:
			return True
	return False
for _ in range(int(input())):
	n = int(input())
	s = input()
	if n % 2 == 1:
		if fu(s, 0, n, 0):
			print(1)
		else:
			print(2)
	elif fu(s, 1, n, 1):
		print(2)
	else:
		print(1)


from math import *
from collections import *
from itertools import *
from functools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input()))
	(f1, f2) = (0, 0)
	for (i, x) in enumerate(l):
		if i & 1:
			if not x & 1:
				f2 = 1
		elif x & 1:
			f1 = 1
	if not n & 1:
		if f2:
			print(2)
		else:
			print(1)
	elif f1:
		print(1)
	else:
		print(2)


def read_int():
	inp = map(int, input().strip().split())
	return inp

def test():
	(n,) = read_int()
	s = input().strip()
	count = {0: {0: 0, 1: 0}, 1: {0: 0, 1: 0}}
	for (i, v) in enumerate(s, 1):
		v = int(v)
		count[i % 2][v % 2] += 1
	if n % 2:
		if count[1][1]:
			print(1)
		else:
			print(2)
	elif count[0][0]:
		print(2)
	else:
		print(1)
(t,) = read_int()
for _ in range(t):
	test()


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = I()
	e = o = 0
	for (i, j) in enumerate(map(int, S()), 1):
		if i & 1 == j & 1 == 1:
			o += 1
		elif i & 1 == j & 1 == 0:
			e += 1
	if n & 1:
		print(1 if o else 2)
	else:
		print(2 if e else 1)


def iinput():
	return int(input())

def finput():
	return float(input())
T = iinput()
for _ in range(T):
	ee = 0
	eo = 0
	oe = 0
	oo = 0
	n = iinput()
	s = input()
	for i in range(len(s)):
		if (i + 1) % 2 == 0:
			if int(s[i]) % 2 == 0:
				ee += 1
			else:
				eo += 1
		elif int(s[i]) % 2 == 0:
			oe += 1
		else:
			oo += 1
	if n % 2 == 1:
		if oo > 0:
			print(1)
		else:
			print(2)
	elif ee > 0:
		print(2)
	else:
		print(1)


def f():
	n = int(input())
	c = input()
	leftc = 0
	rightc = 0
	for i in range(1, n + 1):
		if int(c[i - 1]) % 2 == 0 and i % 2 == 1:
			leftc = leftc + 1
		if int(c[i - 1]) % 2 == 1 and i % 2 == 0:
			rightc = rightc + 1
	if n % 2 == 0:
		if rightc > n / 2 - 1:
			return 1
		else:
			return 2
	elif leftc > (n + 1) / 2 - 1:
		return 2
	else:
		return 1
t = int(input())
a = [0] * t
for i in range(t):
	a[i] = f()
for i in range(t):
	print(a[i])


from sys import stdin, stdout

def gmi():
	return map(int, stdin.readline().strip().split())

def gms():
	return map(str, stdin.readline().strip().split())

def gari():
	return list(map(int, stdin.readline().strip().split()))

def gars():
	return list(map(int, stdin.readline().strip().split()))

def gs():
	return stdin.readline().strip()

def gls():
	return list(stdin.readline().strip())

def gi():
	return int(stdin.readline())

def p(x):
	stdout.write(str(x) + ' ')

def pn(x):
	stdout.write(str(x) + '\n')

def par(ar):
	stdout.write(' '.join((str(x) for x in ar)) + '\n')
t = gi()
while t:
	t -= 1
	n = gi()
	num = gs()
	o = e = O = E = 0
	x = True
	for i in num:
		if x and int(i) & 1:
			o += 1
		elif not x and (not int(i) & 1):
			e += 1
		if o and e:
			break
		x = not x
	if n & 1:
		if o:
			print(1)
		else:
			print(2)
	elif e:
		print(2)
	else:
		print(1)


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(99999)

def solve():
	n = int(input())
	sn = input().strip()
	if n & 1:
		for i in range(0, n, 2):
			if sn[i] in '13579':
				return 1
		return 2
	else:
		for i in range(1, n, 2):
			if sn[i] in '24680':
				return 2
		return 1
t = int(input())
for _ in range(t):
	print(solve())


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	inp = input()
	if n % 2:
		for (idx, i) in enumerate(inp):
			if idx % 2 == 0 and int(i) % 2:
				print('1')
				break
		else:
			print('2')
	else:
		for (idx, i) in enumerate(inp):
			if idx % 2 and int(i) % 2 == 0:
				print('2')
				break
		else:
			print('1')


t = int(input())
for w in range(t):
	n = int(input())
	a = input()
	r = False
	b = False
	for (i, x) in enumerate(a):
		if i % 2 == 1 and int(x) % 2 == 0:
			b = True
		elif i % 2 == 0 and int(x) % 2 == 1:
			r = True
		if r and b:
			break
	if n % 2 == 0:
		if b:
			print(2)
		else:
			print(1)
	elif r:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	val = list(map(int, list(input())))
	if n % 2 == 1:
		flag = 0
		for i in range(0, len(val), 2):
			if val[i] % 2 == 1:
				flag = 1
		if flag == 1:
			print(1)
		else:
			print(2)
	else:
		flag = 0
		for i in range(1, len(val), 2):
			if val[i] % 2 == 0:
				flag = 1
		if flag == 1:
			print(2)
		else:
			print(1)


for i in range(int(input())):
	n = int(input())
	m = input()
	(a, b, c, d) = (0, 0, 0, 0)
	for i in range(n):
		if i % 2 == 0:
			if int(m[i]) % 2 == 0:
				a = a + 1
			else:
				b = b + 1
		elif int(m[i]) % 2 == 0:
			c = c + 1
		else:
			d = d + 1
	if n % 2 == 0:
		if c:
			print(2)
		else:
			print(1)
	elif b:
		print(1)
	else:
		print(2)


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input()]
	win = 0
	if n & 1:
		for i in a[::2]:
			if i & 1:
				win = 1
	else:
		for i in a[1::2]:
			if i & 1:
				win += 1
		if win == n // 2:
			win = 1
		else:
			win = 0
	print([2, 1][win])


T = int(input())
for _ in range(T):
	N = int(input())
	S = input()
	if N % 2:
		hasodd = False
		for c in S[::2]:
			if int(c) % 2:
				hasodd = True
		print(1 if hasodd else 2)
	else:
		haseven = False
		for c in S[1::2]:
			if int(c) % 2 == 0:
				haseven = True
		print(2 if haseven else 1)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, list(input())))
	odd = 0
	even = 0
	for j in range(n):
		if j % 2 == 0 and s[j] % 2 != 0:
			odd += 1
		elif j % 2 != 0 and s[j] % 2 == 0:
			even += 1
	if n % 2 == 0:
		if even != 0:
			print(2)
		else:
			print(1)
	elif odd != 0:
		print(1)
	else:
		print(2)


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {'opos_e': 0, 'opos_o': 0, 'epos_e': 0, 'epos_o': 0}
	for i in range(n):
		tmp = int(s[i])
		if (i + 1) % 2 == 1:
			if tmp % 2 == 0:
				d['opos_e'] += 1
			else:
				d['opos_o'] += 1
		elif tmp % 2 == 0:
			d['epos_e'] += 1
		else:
			d['epos_o'] += 1
	for i in range(n - 1):
		if (i + 1) % 2 == 1:
			if d['opos_e'] - 1 >= 0:
				d['opos_e'] -= 1
			else:
				d['opos_o'] -= 1
		elif d['epos_o'] - 1 >= 0:
			d['epos_o'] -= 1
		else:
			d['epos_e'] -= 1
	if d['opos_e'] == 1 or d['epos_e'] == 1:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	even = True
	odd = True
	for (i, x) in enumerate(s):
		if i & 1 ^ 1:
			even &= int(x) & 1 ^ 1
		else:
			odd &= int(x) & 1
	if n & 1:
		print(even + 1)
	else:
		print((odd ^ 1) + 1)


from sys import stdin
for _ in range(int(input())):
	n = int(input())
	l = list(stdin.readline().rstrip())
	ev = od = False
	for i in range(n):
		if (i + 1) % 2 and int(l[i]) % 2:
			od = True
		if (i + 1) % 2 == 0 and int(l[i]) % 2 == 0:
			ev = True
	if n % 2:
		if od:
			print(1)
		else:
			print(2)
	elif ev:
		print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input()))
	odd = even = False
	for i in range(1, n + 1):
		if i % 2 == 1:
			if l[i - 1] % 2 == 1:
				odd = True
		elif l[i - 1] % 2 == 0:
			even = True
	if n % 2 == 1:
		print('1' if odd else '2')
	else:
		print('2' if even else '1')


def solve(n, num):
	num_str = str(num)
	odds = []
	evens = []
	for (i, c) in enumerate(num_str):
		if (i + 1) % 2 == 0:
			evens.append(int(c) % 2)
		else:
			odds.append(int(c) % 2)
	if len(num_str) % 2 == 0:
		if sum(evens) < len(evens):
			return 2
		else:
			return 1
	elif sum(odds) > 0:
		return 1
	else:
		return 2
t = int(input())
for i in range(t):
	n = int(input())
	num = int(input())
	print(solve(n, num))


t = int(input())
for i in range(t):
	totalLen = int(input())
	totalInp = list(map(int, list(input())))
	if totalLen % 2 != 0:
		coOdd = 0
		for i in range(0, totalLen, 2):
			if totalInp[i] % 2 != 0:
				coOdd = 1
				print('1')
				break
		if coOdd == 0:
			print('2')
	else:
		coOdd = 0
		for i in range(1, totalLen, 2):
			if totalInp[i] % 2 == 0:
				coOdd = 1
				print('2')
				break
		if coOdd == 0:
			print('1')


t = int(input())
for i in range(t):
	b = int(input())
	a = input()
	if b % 2 == 0:
		h = 1
		for j in range(1, b, 2):
			if int(a[j]) % 2 == 0:
				h = 0
				break
		if h == 1:
			print('1')
		else:
			print('2')
	else:
		g = 1
		for j in range(0, b, 2):
			if int(a[j]) % 2 != 0:
				g = 0
				break
		if g == 0:
			print('1')
		else:
			print('2')


from math import ceil, floor
t = int(input())
for _ in range(t):
	n = int(input())
	digit = str(input())[:n]
	arr = [int(i) for i in digit]
	raze_total_turns = ceil((n - 1) / 2)
	breach_total_turns = floor((n - 1) / 2)
	total_even = 0
	total_odd = 0
	even_at_even_pos = 0
	odd_at_odd_pos = 0
	for i in arr:
		if i % 2 == 0:
			total_even += 1
		else:
			total_odd += 1
	for i in range(0, n, 2):
		if arr[i] % 2 == 0:
			even_at_even_pos += 1
	for i in range(1, n, 2):
		if arr[i] % 2 != 0:
			odd_at_odd_pos += 1
	even_at_even_pos = min(even_at_even_pos, raze_total_turns)
	odd_at_odd_pos = min(odd_at_odd_pos, breach_total_turns)
	total_even -= even_at_even_pos
	total_odd -= raze_total_turns - even_at_even_pos
	total_odd -= odd_at_odd_pos
	total_even -= breach_total_turns - odd_at_odd_pos
	if total_odd == 1:
		print(1)
	elif total_even == 1:
		print(2)
	else:
		print('error')


from collections import defaultdict

def ans(N):
	num = defaultdict(int)
	for (i, e) in enumerate(N):
		e = int(e) % 2
		i = 1 - i % 2
		num[i, e] += 1
	if len(N) % 2 == 1:
		if num[1, 1] > 0:
			return 1
		else:
			return 2
	elif num[0, 0] > 0:
		return 2
	else:
		return 1
	return '?'
T = int(input())
for t in range(T):
	input()
	N = input()
	print(ans(N))


for t in range(int(input())):
	n = int(input())
	a = input()
	a2 = 0
	b1 = 0
	for i in range(len(a)):
		if (i + 1) % 2 == 0:
			if int(a[i]) % 2 == 0:
				b1 += 1
		elif int(a[i]) % 2 != 0:
			a2 += 1
	if n % 2 == 0:
		if b1 > 0:
			print(2)
		else:
			print(1)
	elif a2 > 0:
		print(1)
	else:
		print(2)


test = int(input())
for q in range(test):
	n = int(input())
	x = input()
	(ee, oo) = (0, 0)
	for i in range(1, n + 1):
		if i % 2 == 0 and int(x[i - 1]) % 2 == 0:
			ee += 1
		elif i % 2 == 1 and int(x[i - 1]) % 2 == 1:
			oo += 1
	if n % 2 == 0:
		if ee > 0:
			print(2)
		else:
			print(1)
	elif oo > 0:
		print(1)
	else:
		print(2)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		s = S()
		s = [int(c) for c in s]
		if n % 2:
			r = any((c % 2 for c in s[::2]))
		else:
			r = all((c % 2 for c in s[1::2]))
		rr.append(IF(r, 1, 2))
	return JA(rr, '\n')
print(main())


def solve():
	n = int(input())
	num = input()
	temBreach = False
	temRaizel = False
	for i in range(n):
		if i % 2 == 0 and int(num[i]) % 2 == 1:
			temRaizel = True
		elif i % 2 == 1 and int(num[i]) % 2 == 0:
			temBreach = True
	if n % 2 == 0 and temBreach:
		print(2)
	elif n % 2 == 1 and temRaizel:
		print(1)
	elif n % 2 == 1 and (not temRaizel):
		print(2)
	else:
		print(1)

def main():
	t = int(input())
	while t:
		t = t - 1
		solve()
main()


for _ in [0] * int(input()):
	n = int(input())
	s = list(input())
	if n % 2 and (not len([i for i in s[::2] if int(i) % 2])) or (not n % 2 and len([j for j in s[1::2] if not int(j) % 2])):
		print(2)
	else:
		print(1)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
import threading
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')
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	s = input()
	odd1 = 0
	evn2 = 0
	for i in range(n):
		if (ord(s[i]) - ord('0')) % 2 != 0 and i % 2 == 0:
			odd1 += 1
		elif (ord(s[i]) - ord('0')) % 2 == 0 and i % 2 != 0:
			evn2 += 1
	if n % 2 == 0:
		if evn2 > 0:
			print(2)
		else:
			print(1)
	elif odd1 > 0:
		print(1)
	else:
		print(2)


t = int(input())
for i in range(t):
	n = int(input())
	v = input()
	odd = 0
	even = 0
	if n % 2 == 0:
		i = 1
		while even == 0 and i < n:
			if int(v[i]) % 2 == 0:
				even += 1
			i += 2
		if even == 0:
			print(1)
		else:
			print(2)
		print()
	else:
		i = 0
		while even == 0 and i < n:
			if int(v[i]) % 2 == 1:
				odd += 1
			i += 2
		if odd == 0:
			print(2)
		else:
			print(1)


t = int(input())
n = []
digit = []
for i in range(t):
	e = int(input())
	w = list(map(int, input()))
	digit.append(w)
	n.append(e)

def rob(n, a):
	eve = []
	odd = []
	count_odd_in_eve = 0
	count_odd_in_odd = 0
	count_eve_in_odd = 0
	count_eve_in_eve = 0
	for i in range(n):
		if (i + 1) % 2 == 0:
			eve.append(a[i])
		else:
			odd.append(a[i])
	for i in range(len(eve)):
		if eve[i] % 2 == 0:
			count_eve_in_eve += 1
		else:
			count_odd_in_eve += 1
	for i in range(len(odd)):
		if odd[i] % 2 == 0:
			count_eve_in_odd += 1
		else:
			count_odd_in_odd += 1
	flag = 1
	for i in range(n - 1):
		if flag == 1:
			if count_eve_in_odd != 0:
				count_eve_in_odd -= 1
			else:
				count_odd_in_odd -= 1
		elif count_odd_in_eve != 0:
			count_odd_in_eve -= 1
		else:
			count_eve_in_eve -= 1
		flag = flag * -1
	if count_eve_in_eve > 0:
		return 2
	elif count_eve_in_odd > 0:
		return 2
	elif count_odd_in_eve > 0:
		return 1
	elif count_odd_in_odd > 0:
		return 1
for i in range(t):
	q = rob(n[i], digit[i])
	print(q)


from sys import stdin, stdout
t = int(stdin.readline())
for case in range(t):
	n = int(stdin.readline())
	s = stdin.readline().strip('\n')
	winner = -1
	if len(s) % 2 == 1:
		odd = False
		for i in range(0, len(s), 2):
			if int(s[i]) % 2 == 1:
				odd = True
				break
		if odd:
			winner = 1
		else:
			winner = 2
	else:
		even = False
		for i in range(1, len(s), 2):
			if int(s[i]) % 2 == 0:
				even = True
				break
		if even:
			winner = 2
		else:
			winner = 1
	stdout.write('{}\n'.format(winner))


a = int(input())
for i in range(0, a):
	t = int(input())
	b = int(input())
	arr = []
	while b > 0:
		arr.append(b % 10)
		b = b // 10
	even = []
	odd = []
	for i in arr:
		if i % 2 == 0:
			even.append(i)
		else:
			odd.append(i)
	arr = arr[::-1]
	o = 0
	for i in range(0, len(arr)):
		if (i + 1) % 2 == 1:
			if arr[i] % 2 == 1:
				o = 1
				break
	e = 0
	for i in range(0, len(arr)):
		if (i + 1) % 2 == 0:
			if arr[i] % 2 == 0:
				e = 1
				break
	if t % 2 == 1:
		if o == 1:
			print(1)
		else:
			print(2)
	elif e == 1:
		print(2)
	else:
		print(1)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	cntR = 0
	cntB = 0
	j = 0
	while j < n:
		if int(s[j]) % 2 == 1:
			cntR += 1
		j += 2
	j = 1
	while j < n:
		if int(s[j]) % 2 == 0:
			cntB += 1
		j += 2
	if n % 2 == 1:
		if cntR > 0:
			print(1, end='\n')
		else:
			print(2, end='\n')
	elif cntB > 0:
		print(2, end='\n')
	else:
		print(1, end='\n')


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import threading
import sys
import time

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	n = get_int()
	ls = [int(val) for val in input()]
	if n == 1:
		return 1 if ls[0] % 2 else 2
	if n % 2:
		for i in range(0, n, 2):
			if ls[i] % 2:
				return 1
		return 2
	else:
		for i in range(1, n, 2):
			if ls[i] % 2 == 0:
				return 2
		return 1

def main():
	print(solve())
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
for _ in range(int(input())):
	n = input()
	a = list(input())
	ec = 0
	oc = 0
	z = len(a)
	if z % 2 == 0:
		for i in range(z):
			if i % 2 != 0:
				if int(a[i]) % 2 == 0:
					ec += 1
					break
		if ec == 1:
			print(2)
		else:
			print(1)
	else:
		for i in range(z):
			if i % 2 == 0:
				if int(a[i]) % 2 != 0:
					oc += 1
					break
		if oc == 1:
			print(1)
		else:
			print(2)


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		N = int(input())
		D = input()
		if N % 2:
			for i in range(0, N, 2):
				if int(D[i]) % 2:
					print(1)
					break
			else:
				print(2)
		else:
			for i in range(1, N, 2):
				if not int(D[i]) % 2:
					print(2)
					break
			else:
				print(1)
main()


import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq
INF = 10 ** 20
MOD = 998244353
ni = lambda : int(sys.stdin.readline().rstrip())
ns = lambda : map(int, sys.stdin.readline().rstrip().split())
na = lambda : list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda : list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
flush = lambda : sys.stdout.flush()

def main():
	t = ni()
	for _ in range(t):
		l = ni()
		s = input()
		odd_odd = 0
		odd_even = 0
		even_odd = 0
		even_even = 0
		for (i, si) in enumerate(s):
			tsi = int(si)
			if not i % 2:
				if tsi % 2:
					odd_odd += 1
				else:
					odd_even += 1
			elif tsi % 2:
				even_odd += 1
			else:
				even_even += 1
		if l % 2:
			if odd_odd > 0:
				print(1)
			else:
				print(2)
		elif even_even:
			print(2)
		else:
			print(1)
main()


import math
import sys
test = int(input())
for _ in range(test):
	ln = int(input())
	n = input()
	(c1, c2, c3, c4) = (0, 0, 0, 0)
	for j in range(len(n)):
		k = int(n[j])
		if j % 2 == 0:
			if k % 2 == 0:
				c1 += 1
			if k % 2 != 0:
				c2 += 1
		else:
			if k % 2 == 0:
				c3 += 1
			if k % 2 != 0:
				c4 += 1
	if len(n) % 2 == 0 and c3 != 0:
		print(2)
	elif len(n) % 2 == 0 and c3 == 0:
		print(1)
	elif len(n) % 2 != 0 and c2 != 0:
		print(1)
	elif len(n) % 2 != 0 and c2 == 0:
		print(2)


for t in range(int(input())):
	n = int(input())
	arr = input()
	if len(arr) % 2 != 0:
		res = 2
		for i in range(0, len(arr), 2):
			if int(arr[i]) % 2 != 0:
				res = 1
				break
	else:
		res = 1
		for i in range(1, len(arr), 2):
			if int(arr[i]) % 2 == 0:
				res = 2
				break
	print(res)


t = int(input())

def solve(n, s):
	has_odd = False
	has_even = False
	for i in range(n):
		if i % 2 == 0 and int(s[i]) % 2 == 1:
			has_odd = True
		if i % 2 == 1 and int(s[i]) % 2 == 0:
			has_even = True
	if n % 2 == 1:
		if has_odd:
			return 1
		else:
			return 2
	elif has_even:
		return 2
	else:
		return 1
for _ in range(t):
	n = int(input())
	s = input()
	print(solve(n, s))


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	l = int(input())
	n = input().strip()
	if l % 2:
		ep = l // 2
		op = l // 2 + 1
	else:
		ep = l // 2
		op = l // 2
	e = 0
	o = 0
	for (i, j) in enumerate(n, 1):
		if int(j) % 2 and i % 2 == 0:
			o += 1
		if int(j) % 2 == 0 and i % 2:
			e += 1
	if l % 2:
		if op == e:
			ans = 2
		else:
			ans = 1
	elif ep == o:
		ans = 1
	else:
		ans = 2
	print(ans)


for T in range(int(input())):
	n = int(input())
	s = input()
	a = list(map(int, s))
	(odd_c, even_c) = (0, 0)
	for i in range(n):
		if i & 1 == 0:
			if a[i] & 1:
				odd_c += 1
		elif a[i] & 1 == 0:
			even_c += 1
	if n == 1:
		if a[0] & 1:
			print('1')
		else:
			print('2')
	elif n & 1:
		if odd_c != 0:
			print('1')
		else:
			print('2')
	elif even_c != 0:
		print('2')
	else:
		print('1')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	oddAmount = 0
	evenAmount = 0
	if n % 2 != 0:
		for j in range(0, n, 2):
			if int(s[j]) % 2 == 1:
				oddAmount += 1
			else:
				evenAmount += 1
		if oddAmount > 0:
			print(1)
		else:
			print(2)
	else:
		for j in range(1, n, 2):
			if int(s[j]) % 2 == 1:
				oddAmount += 1
			else:
				evenAmount += 1
		if evenAmount > 0:
			print(2)
		else:
			print(1)


n = int(input())
i = 0
while i < n:
	_ = input()
	ch = input()
	mas = [0, 0, 0, 0]
	for j in range(len(ch)):
		if (j + 1) % 2 == 0 and int(ch[j]) % 2 == 0:
			mas[0] += 1
		elif (j + 1) % 2 == 0 and int(ch[j]) % 2 != 0:
			mas[1] += 1
		elif (j + 1) % 2 != 0 and int(ch[j]) % 2 == 0:
			mas[2] += 1
		elif (j + 1) % 2 != 0 and int(ch[j]) % 2 != 0:
			mas[3] += 1
	if mas[0] + mas[1] < mas[2] + mas[3]:
		if mas[3] > 0:
			print('1')
		else:
			print('2')
	elif mas[0] > 0:
		print('2')
	else:
		print('1')
	i += 1


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	k = input()
	has = [[0] * 2 for i in range(2)]
	for i in range(1, n + 1):
		has[i % 2][int(k[i - 1]) % 2] = 1
	if n % 2 == 0:
		if has[0][0]:
			print(2)
		else:
			print(1)
	elif has[1][1]:
		print(1)
	else:
		print(2)


t = int(input())
for p in range(t):
	n = int(input())
	num = int(input())
	digreg = []
	digblz = []
	if n == 1:
		if num % 2 == 0:
			print('2')
		else:
			print('1')
		continue
	if n % 2 == 1:
		par = 1
	else:
		par = -1
	while num > 0:
		rem = num % 10
		if par == 1:
			digreg.append(rem)
		else:
			digblz.append(rem)
		par *= -1
		num = num // 10
	if n % 2 == 1:
		fl = 0
		for k in digreg:
			if k % 2 == 1:
				fl = 1
				break
		if fl == 1:
			print('1')
		else:
			print('2')
	else:
		fl = 0
		for k in digblz:
			if k % 2 == 0:
				fl = 1
				break
		if fl == 1:
			print('2')
		else:
			print('1')


for _ in range(int(input())):
	n = int(input())
	integer = input()
	c = 0
	e = 0
	if n % 2 == 0:
		for i in range(n):
			if int(integer[i]) % 2 == 0 and (i + 1) % 2 == 0:
				c += 1
		print('2' if c > 0 else '1')
	else:
		for i in range(n):
			if int(integer[i]) % 2 != 0 and (i + 1) % 2 != 0:
				e += 1
		print('1' if e > 0 else '2')


T = int(input())
for _ in range(0, T):
	n1 = int(input())
	n = int(input())
	s = str(n)
	temp1 = 0
	temp2 = 0
	for i in range(0, len(s)):
		if i % 2 == 0:
			if int(s[i]) % 2 != 0:
				temp1 = 1
		elif int(s[i]) % 2 == 0:
			temp2 = 1
	if n1 % 2 == 0:
		if temp2 == 0:
			print(1)
		else:
			print(2)
	elif temp1 == 0:
		print(2)
	else:
		print(1)


for _ in range(int(input())):
	i_liczb = int(input())
	liczby = list(input())
	if i_liczb % 2 == 0:
		for x in range(1, i_liczb, 2):
			if int(liczby[x]) % 2 == 0:
				print(2)
				break
		else:
			print(1)
	else:
		for x in range(0, i_liczb, 2):
			if int(liczby[x]) % 2 == 1:
				print(1)
				break
		else:
			print(2)


t = int(input())
while t:
	t -= 1
	n = int(input())
	no = list(map(int, input()))
	if n == 1:
		if no[0] % 2 == 0:
			print(2)
		else:
			print(1)
	elif n % 2 == 0:
		c = 1
		for i in range(1, n, 2):
			if no[i] % 2 == 0:
				c = 2
				break
		print(c)
	else:
		c = 2
		for i in range(0, n, 2):
			if no[i] % 2 != 0:
				c = 1
				break
		print(c)


x = int(input())
for i in range(0, x):
	a = int(input())
	d = input()
	(x, y) = (0, 0)
	if a % 2 == 0:
		s = 0
		while s < len(d):
			if int(d[s + 1]) % 2 == 0:
				x = x + 1
				break
			s = s + 2
		if x == 0:
			print('1')
		else:
			print('2')
	else:
		s = 0
		while s < len(d):
			if int(d[s]) % 2 != 0:
				x = x + 1
				break
			s = s + 2
		if x == 0:
			print('2')
		else:
			print('1')


n = int(input())
for i in range(n):
	l = int(input())
	k = input()
	c = 0
	if l % 2 != 0 and l > 1:
		for j in range(int(l / 2) + 1):
			if int(k[2 * j]) % 2 != 0:
				print(1)
				c = c + 1
				break
		if c == 0:
			print(2)
	if l % 2 == 0 and l > 1:
		for j in range(int(l / 2)):
			if int(k[2 * j + 1]) % 2 == 0:
				print(2)
				c = c + 1
				break
		if c == 0:
			print(1)
	if l == 1:
		if int(k) % 2 == 0:
			print(2)
		else:
			print(1)


def evod(n):
	if n % 2 == 0:
		return 1
	else:
		return 0
t = int(input())
for i in range(0, t):
	n = int(input())
	g = int(input())
	lst = [int(j) for j in str(g)]
	if len(lst) % 2 == 0 and len(lst) != 1:
		breach = []
		k = 1
		while k < len(lst):
			breach.append(lst[k])
			k += 2
		for l in breach:
			if evod(l) == 1:
				print(2)
				break
			else:
				continue
		else:
			print(1)
	elif len(lst) == 1:
		if evod(lst[0]) == 1:
			print(2)
		else:
			print(1)
	else:
		raze = []
		m = 0
		while m < len(lst):
			raze.append(lst[m])
			m += 2
		for o in raze:
			if evod(o) == 0:
				print(1)
				break
			else:
				continue
		else:
			print(2)


t = int(input())
f = lambda x: int(x) % 2
for _ in range(t):
	n = int(input())
	arr = list(map(f, input()))
	if n > 1:
		raze = arr[0::2]
		breach = [1 - q for q in arr[1::2]]
		if n % 2:
			print(2 - any(raze))
		else:
			print(1 + any(breach))
	else:
		print(2 - arr[0])


from math import ceil, floor
for _ in range(int(input())):
	n = int(input())
	s = input()
	arr = [int(i) for i in s]
	raze = [arr[i] for i in range(n) if i % 2 == 0]
	breach = [arr[i] for i in range(n) if i % 2 == 1]
	for i in range(ceil(n / 2)):
		if raze[i] % 2 == 1:
			k = raze.pop(i)
			raze.append(k)
	for i in range(n // 2):
		if breach[i] % 2 == 0:
			k = breach.pop(i)
			breach.append(k)
	if n % 2 == 0:
		if breach[-1] % 2 == 0:
			print(2)
		else:
			print(1)
	elif raze[-1] % 2 == 0:
		print(2)
	else:
		print(1)


for j in range(int(input())):
	n = int(input())
	l = input()
	if n == 1:
		if int(l) % 2 == 0:
			print('2')
		else:
			print('1')
		continue
	if n % 2 == 0:
		cnt = 0
		for i in range(1, n, 2):
			if int(l[i]) % 2:
				cnt += 1
		if cnt == n / 2:
			print('1')
		else:
			print('2')
	else:
		cnt = 0
		for i in range(0, n, 2):
			if int(l[i]) % 2 == 0:
				cnt += 1
		if cnt == n / 2 + 0.5:
			print('2')
		else:
			print('1')


import sys

def inp():
	return sys.stdin.readline().rstrip('\n').encode('utf8')

def mpint():
	return map(int, sys.stdin.readline().split(' '))

def itg():
	return int(sys.stdin.readline())
for __ in range(itg()):
	n = itg()
	s = inp()
	oo = oe = eo = ee = 0
	for (i, c) in enumerate(s):
		i += 1
		c = int(c)
		if i & 1:
			if c & 1:
				oo += 1
			else:
				oe += 1
		elif c & 1:
			eo += 1
		else:
			ee += 1
	for t in range(1, n):
		if t & 1:
			if oe:
				oe -= 1
			else:
				oo -= 1
		elif eo:
			eo -= 1
		else:
			ee -= 1
	if eo or oo:
		print(1)
	else:
		print(2)


for i in range(int(input())):
	n = int(input())
	nd = str(input())
	ndi = int(nd)
	if n == 1:
		if ndi % 2 != 0:
			print(1)
		else:
			print(2)
	else:
		l1 = []
		l2 = []
		for i in range(len(nd)):
			if i % 2 == 0:
				l1.append(int(nd[i]))
			else:
				l2.append(int(nd[i]))
		count = 0
		while len(l1) > 0 and len(l2) > 0:
			if count % 2 == 0:
				flag1 = 0
				for i in l1:
					z1 = i
					if i % 2 == 0:
						l1.remove(i)
						flag1 = 1
						break
				if flag1 == 0:
					l1.remove(z1)
			else:
				flag = 0
				for i in l2:
					z = i
					if i % 2 != 0:
						l2.remove(i)
						flag = 1
						break
				if flag == 0:
					l2.remove(z)
			count += 1
		if len(l1) == 0:
			if l2[0] % 2 == 0:
				print(2)
			else:
				print(1)
		elif l1[0] % 2 == 0:
			print(2)
		else:
			print(1)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, list(input())))
	r = s[::2]
	b = s[1::2]
	flag = 0
	if len(r) > len(b):
		for i in r:
			if i % 2:
				flag = 1
				break
	else:
		cnt = 0
		for i in b:
			if i % 2:
				cnt += 1
		if cnt == len(b):
			flag = 1
	if flag:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	num = int(input())
	arr = list(str(num))
	razeeven = 0
	razeodd = 0
	beven = 0
	bodd = 0
	for i in range(n):
		if i % 2 == 0:
			if int(arr[i]) % 2 == 0:
				razeeven += 1
			else:
				razeodd += 1
		elif int(arr[i]) % 2 == 0:
			beven += 1
		else:
			bodd += 1
	i = 1
	while i < n:
		if i % 2 == 0:
			if bodd > 0:
				bodd -= 1
			else:
				beven -= 1
		elif razeeven > 0:
			razeeven -= 1
		else:
			razeodd -= 1
		i += 1
	if bodd != 0 or razeodd != 0:
		print(1)
	else:
		print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	digits = input()
	if len(digits) == 1:
		if int(digits) % 2 == 0:
			print(2)
		else:
			print(1)
	elif len(digits) % 2 == 0:
		hasEven = False
		for i in range(1, n, 2):
			if int(digits[i]) % 2 == 0:
				hasEven = True
				break
		if hasEven:
			print(2)
		else:
			print(1)
	else:
		hasOdd = False
		for i in range(0, n, 2):
			if int(digits[i]) % 2 == 1:
				hasOdd = True
				break
		if hasOdd:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	a = int(input())
	b = input()
	c = list(map(int, b))
	d = 0
	if a % 2 == 0:
		for i in range(len(c)):
			if i % 2 != 0 and c[i] % 2 == 0:
				d += 1
				break
		if d == 1:
			print(2)
		else:
			print(1)
	else:
		for i in range(len(c)):
			if i % 2 == 0 and c[i] % 2 != 0:
				d += 1
				break
		if d == 1:
			print(1)
		else:
			print(2)


for _ in range(int(input())):
	n = int(input())
	num = input()
	odd_at_odd_pos = any([int(dig) & 1 for dig in num[::2]])
	even_at_even_pos = any([not int(dig) & 1 for dig in num[1::2]])
	if n & 1:
		if odd_at_odd_pos:
			print(1)
		else:
			print(2)
	elif even_at_even_pos:
		print(2)
	else:
		print(1)


t = int(input())
for _ in range(t):
	n = int(input())
	x = str(input())
	b = []
	bc = 0
	r = []
	rc = 0
	if n == 1:
		if int(x) % 2 == 0:
			print(2)
		else:
			print(1)
	else:
		for i in range(1, n + 1):
			if i % 2 == 0:
				b.append(int(x[i - 1]))
				if int(x[i - 1]) % 2 == 0:
					bc += 1
			else:
				r.append(int(x[i - 1]))
				if int(x[i - 1]) % 2 == 1:
					rc += 1
		if n % 2 == 0:
			if bc >= 1:
				print(2)
			else:
				print(1)
		elif rc >= 1:
			print(1)
		else:
			print(2)


import sys
from collections import defaultdict
name = sys.stdin.read()
jobGrid = []
isJob = True
row = []
grid = name.split('\n')
grid = grid[:-1]
number_of_cases = int(grid[0])
for i in range(number_of_cases):
	winner = 0
	number_of_digits = list(map(int, grid[i * 2 + 1].split()))[0]
	ndigit = list(map(str, grid[i * 2 + 2].split()))[0]
	breachstart = number_of_digits % 2 == 0
	if number_of_digits == 1:
		winner = 2 - int(ndigit[0]) % 2
	if breachstart:
		for j in range(1, len(ndigit), 2):
			if int(ndigit[j]) % 2 == 0:
				winner = 2
				break
			else:
				winner = 1
	else:
		for j in range(0, len(ndigit), 2):
			if int(ndigit[j]) % 2 == 1:
				winner = 1
				break
			else:
				winner = 2
	print(winner)


for _ in range(int(input())):
	am = int(input())
	n = list(map(int, list(input())))
	odd1 = 0
	even1 = 0
	odd2 = 0
	even2 = 0
	for i in range(am):
		if (i + 1) % 2 == 1:
			if n[i] % 2 == 1:
				odd1 += 1
			else:
				even1 += 1
		elif n[i] % 2 == 1:
			odd2 += 1
		else:
			even2 += 1
	if am % 2 == 1:
		if odd1 >= 1:
			print(1)
		else:
			print(2)
	elif even2 >= 1:
		print(2)
	else:
		print(1)


t = int(input())
answers = []
for _ in range(t):
	n = int(input())
	s = input()
	odd = even = False
	for i in range(1, n + 1):
		if i % 2 == 1:
			odd |= int(s[i - 1]) % 2 == 1
		else:
			even |= int(s[i - 1]) % 2 == 0
	if n % 2 == 1:
		if odd:
			answers.append(1)
		else:
			answers.append(2)
	elif even:
		answers.append(2)
	else:
		answers.append(1)
print(*answers, sep='\n')


def digitGame(string):
	n = len(string)
	if n % 2 == 0:
		for i in range(1, n, 2):
			digit = int(string[i])
			if digit % 2 == 0:
				return 2
		return 1
	else:
		for i in range(0, n, 2):
			digit = int(string[i])
			if digit % 2 != 0:
				return 1
		return 2
t = int(input())
for _ in range(t):
	n = int(input())
	number = input()
	print(digitGame(number))


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	y = int(x)
	if n == 1:
		if y % 2 == 1:
			print(1)
		else:
			print(2)
	elif n % 2 == 0:
		i = 1
		q = 0
		while i < n:
			if int(x[i]) % 2 == 0:
				q = 1
				print(2)
				break
			i += 2
		if q == 0:
			print(1)
	else:
		i = 0
		q = 0
		while i < n:
			if int(x[i]) % 2 == 1:
				print(1)
				q = 1
				break
			i += 2
		if q == 0:
			print(2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = str(input())
	R = []
	B = []
	for i in range(n):
		t = int(s[i])
		t %= 2
		if i % 2 == 0:
			R.append(t)
		else:
			B.append(t)
	R = set(R)
	B = set(B)
	if n % 2 == 1:
		if 1 in R:
			print(1)
		else:
			print(2)
	elif 0 in B:
		print(2)
	else:
		print(1)


def win(a, n):
	if n % 2:
		for i in range(0, len(a), 2):
			if a[i] % 2:
				return 1
		return 2
	else:
		for i in range(1, len(a), 2):
			if a[i] % 2 == 0:
				return 2
		return 1
t = int(input())
while t:
	n = int(input())
	a = str(input())
	a = list(a)
	a = [int(i) for i in a]
	print(win(a, n))
	t = t - 1


import math

def solve(n, arr):
	if n % 2 == 0:
		for j in range(1, n, 2):
			if int(arr[j]) % 2 == 0:
				return 2
		return 1
		pass
	else:
		for j in range(0, n, 2):
			if int(arr[j]) % 2 != 0:
				return 1
		return 2
		pass
	pass
t = int(input())
ans = []
for i in range(t):
	n = int(input())
	arr = list(input())
	ans.append(solve(n, arr))
for test in ans:
	print(test)


t = int(input())
for i in range(t):
	(ro, be) = (0, 0)
	n = int(input())
	s = list(map(int, input()))
	for i in range(n):
		if i % 2 == 0:
			if s[i] % 2 == 1:
				ro += 1
		elif s[i] % 2 == 0:
			be += 1
	if n % 2 == 1:
		t = 1 if ro > 0 else 2
	else:
		t = 2 if be > 0 else 1
	print(t)


for _ in range(int(input())):
	n = int(input())
	a = int(input())
	e = ''
	o = ''
	a = str(a)
	for i in range(len(a)):
		if i % 2 != 0:
			e = e + a[i]
		else:
			o = o + a[i]
	if n % 2 == 0:
		f = 1
		for i in e:
			if int(i) % 2 == 0:
				print(2)
				f = 0
				break
		if f == 1:
			print(1)
	else:
		f = 1
		for i in o:
			if int(i) % 2 != 0:
				print(1)
				f = 0
				break
		if f == 1:
			print(2)


t = int(input())
for i in range(t):
	n = int(input())
	nums = list(map(int, list(input())))
	RazeOddCount = 0
	RazeEvenCount = 0
	BreachOddCount = 0
	BreachEvenCount = 0
	for j in range(len(nums)):
		if j % 2 == 1:
			if nums[j] % 2 == 0:
				BreachEvenCount += 1
			else:
				BreachOddCount += 1
		elif nums[j] % 2 == 0:
			RazeEvenCount += 1
		else:
			RazeOddCount += 1
	if len(nums) % 2 == 0:
		if BreachEvenCount != 0:
			print('2')
		else:
			print('1')
	elif RazeOddCount != 0:
		print('1')
	else:
		print('2')


import os
import sys
from io import BytesIO, IOBase

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for m in range(t):
	n = inp()
	num = inp()
	tab = [int(x) for x in str(num)]
	perd = 0
	if n % 2 == 0:
		for i in range(n // 2):
			if tab[2 * i + 1] % 2 == 0:
				print(2)
				perd = 1
				break
		if perd == 0:
			print(1)
	else:
		for i in range((n + 1) // 2):
			if tab[2 * i] % 2 == 1:
				print(1)
				perd = 1
				break
		if perd == 0:
			print(2)


def solve():
	n = int(input())
	s = list(map(int, input()))
	c = 0
	d = 0
	for i in range(0, n, 2):
		if s[i] % 2 != 0:
			c += 1
	for i in range(1, n, 2):
		if s[i] % 2 == 0:
			d += 1
	if n % 2 != 0:
		print(1 if c > 0 else 2)
	else:
		print(2 if d > 0 else 1)
t = int(input())
i = 0
while i < t:
	solve()
	i += 1


T = int(input())
for t in range(T):
	N = int(input())
	game = input()
	raze = [0, 0]
	breach = [0, 0]
	for i in range(N):
		parity = int(game[i]) % 2
		if i % 2 == 0:
			raze[parity] += 1
		else:
			breach[parity] += 1
	if N % 2 == 0:
		if breach[0] > 0:
			print(2)
		else:
			print(1)
	elif raze[1] > 0:
		print(1)
	else:
		print(2)


y = lambda : int(input())
for _ in range(y()):
	n = y()
	s = input()
	b = len(s) % 2
	d = '1234567890'
	if b:
		for i in d[::2]:
			if i in s[::2]:
				b = 0
	else:
		for i in d[1::2]:
			if i in s[1::2]:
				b = 1
	print(1 + b)


for t in range(int(input())):
	n = int(input())
	a = input()
	raze = list(map(int, list(a[::2])))
	breach = list(map(int, list(a[1::2])))
	razeEv = [ele for ele in raze if ele % 2 == 0]
	razeOd = [ele for ele in raze if ele % 2 != 0]
	breachEv = [ele for ele in breach if ele % 2 == 0]
	breachOd = [ele for ele in breach if ele % 2 != 0]
	for i in range(n - 1):
		if i % 2 == 0:
			if razeEv:
				razeEv.pop()
			else:
				razeOd.pop()
		elif breachOd:
			breachOd.pop()
		else:
			breachEv.pop()
	if razeEv or breachEv:
		print(2)
	else:
		print(1)


t = int(input())
for j in range(t):
	n = int(input())
	a = input()
	r = []
	b = []
	for i in range(n):
		if (i + 1) % 2 == 1 and int(a[i]) % 2 == 1:
			r.append(1)
		elif (i + 1) % 2 == 0 and int(a[i]) % 2 == 0:
			b.append(1)
	if n % 2 == 1 and len(r) >= 1 or (n % 2 == 0 and len(b) == 0):
		print(1)
	else:
		print(2)


for j in range(int(input())):
	a = b = int(0)
	n = int(input())
	l = list(input())
	for i in range(n):
		if i % 2 == 0:
			if int(l[i]) % 2 == 1:
				a = 1
		elif int(l[i]) % 2 == 0:
			b = 1
	if n % 2 == 1 and a == 1:
		print(1)
	elif n % 2 == 1 and a == 0:
		print(2)
	elif n % 2 == 0 and b == 1:
		print(2)
	else:
		print(1)


n = int(input())
for i in range(0, n):
	k = int(input())
	s = input()
	if len(s) == 1:
		if int(s) % 2 == 0:
			print(2)
		else:
			print(1)
	elif k % 2 != 0:
		c = 0
		for i in range(0, k, 2):
			if int(s[i]) % 2 != 0:
				c += 1
		if c >= 1:
			print(1)
		else:
			print(2)
	else:
		c = 0
		for i in range(1, k, 2):
			if int(s[i]) % 2 == 0:
				c += 1
		if c >= 1:
			print(2)
		else:
			print(1)


t = int(input())
while t:
	n = int(input())
	num = input().rstrip()
	(odd, even) = (False, False)
	for i in range(n):
		if i % 2 == 0:
			if int(num[i]) % 2 != 0:
				odd = True
		elif int(num[i]) % 2 == 0:
			even = True
	if n % 2 == 0:
		if even:
			print(2)
		else:
			print(1)
	elif odd:
		print(1)
	else:
		print(2)
	t -= 1


from collections import Counter, defaultdict as dft

def mp():
	return map(int, input().split())

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

def solve():
	n = int(input())
	s = input()
	rage = [0, 0]
	br = [0, 0]
	for i in range(n):
		if i % 2:
			br[int(s[i]) % 2] += 1
		else:
			rage[int(s[i]) % 2] += 1
	if n % 2:
		take = min(n // 2, rage[0])
		rage[1] -= n // 2 - take
		if rage[1] > 0:
			print(1)
		else:
			print(2)
	else:
		take = min(n // 2 - 1, br[1])
		br[0] -= n // 2 - 1 - take
		if br[0] > 0:
			print(2)
		else:
			print(1)
t = int(input())
for _ in range(t):
	solve()


from sys import stdin

def get_int():
	return int(stdin.readline())

def get_str():
	return stdin.readline().strip()

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_array2d(row):
	return [list(map(int, stdin.readline().strip().split())) for _ in range(row)]
T = get_int()
for _ in range(T):
	N = get_int()
	num = get_str()
	flag = 0
	if N & 1:
		flag = 2
		for i in range(0, N, 2):
			if int(num[i]) & 1:
				flag = 1
	else:
		flag = 1
		for i in range(1, N, 2):
			if int(num[i]) % 2 == 0:
				flag = 2
	print(flag)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(opov, opev, epev, epov) = (0, 0, 0, 0)
	for a in range(n):
		if int(s[a]) % 2 == 0:
			if (a + 1) % 2 == 0:
				epev += 1
			else:
				opev += 1
		elif (a + 1) % 2 == 0:
			epov += 1
		else:
			opov += 1
	turn = 0
	while turn < n - 1:
		if turn % 2 == 0:
			if opev != 0:
				opev -= 1
			else:
				opov -= 1
		elif epov != 0:
			epov -= 1
		else:
			epev -= 1
		turn += 1
	if opov + epov != 0:
		print(1)
	else:
		print(2)