Kulyash stays in room that has a single bulb and N buttons. The bulb is initially on.

The initial states of the buttons are stored in a binary string S of length N — if S_{i} is 0, the i-th button is off, and if S_{i} is 1, the i-th button is on. If Kulyash toggles any single button then the state of the bulb reverses i.e. the bulb lights up if it was off and vice versa. 

Kulyash has toggled some buttons and the final states of the buttons are stored in another binary string R of length N. He asks you to determine the final state of the bulb.

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of three lines of input.
- The first line of each test case contains an integer N — the number of buttons.
- The second line of each test case contains a binary string S — the initial states of the buttons.
- The third line of each test case contains a binary string R — the final states of the buttons.

------ Output Format ------ 

For each test case, output on a new line the final state of the bulb (0 for off and 1 for on).

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ N ≤ 100$
$S$ and $R$ are binary strings, i.e, contain only the characters $0$ and $1$.

----- Sample Input 1 ------ 
2
3
000
001
2
00
11

----- Sample Output 1 ------ 
0
1

----- explanation 1 ------ 
Test case $1$: All the buttons are initially off and finally the state of only one button has changed so the state of the bulb reverses once i.e. it turns off.

Test case $2$: All the buttons are initially off and finally the states of two buttons have changed so the state of the bulb reverses twice i.e. it remains on.

Source: codechef | Difficulty: EASY
Tags: Mathematics


Solutions:
t = int(input(''))
for _ in range(t):
	n = int(input(''))
	s = input('')
	r = input('')
	bulb = True
	for i in range(0, n):
		if s[i] != r[i]:
			bulb = not bulb
	if bulb:
		print(1)
	else:
		print(0)


n1 = int(input())
for w in range(n1):
	n2 = int(input())
	x = input()
	y = input()
	c = 0
	for i in range(n2):
		if x[i] != y[i]:
			c += 1
	if c % 2 != 0:
		print('0')
	else:
		print('1')


T = int(input())
for _ in range(T):
	N = int(input())
	S = input()
	R = input()
	if not (S.count('1') - R.count('1')) % 2:
		print(1)
	else:
		print(0)


for t in range(int(input())):
	bulbs = int(input())
	ini = input()
	final = input()
	if (ini.count('1') + final.count('1')) % 2 == 0:
		print(1)
	else:
		print(0)


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	bulb = True
	for i in range(n):
		if a[i] != b[i]:
			bulb = not bulb
	if bulb:
		print(1)
	else:
		print(0)


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


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


for i in range(int(input())):
	x = int(input())
	z = input()
	n = input()
	ans = 0
	for i in range(x):
		if z[i] != n[i]:
			ans += 1
	if ans % 2 == 0:
		print(1)
	else:
		print(0)


n = int(input())
for i in range(n):
	a = int(input())
	s = str(input())
	r = str(input())
	m = 1
	for j in range(0, a):
		if s[j] == r[j]:
			m = m
		else:
			m = not m
	print(int(m))


T = int(input())
for i in range(T):
	N = int(input())
	S = input('')
	R = input('')
	count = 0
	for j in range(N):
		if S[j] != R[j]:
			count = count + 1
	if count % 2 == 0:
		print(1)
	else:
		print(0)


for o in range(int(input())):
	n = int(input())
	s = input()
	r = input()
	x = 0
	k = 0
	while x < n:
		if int(s[x]) != int(r[x]):
			k += 1
			x += 1
		else:
			x += 1
	if k % 2 == 0:
		print('1')
	else:
		print('0')


t = int(input())
for i in range(t):
	N = int(input())
	S = input()
	R = input()
	count = 0
	for i in range(N):
		if S[i] != R[i]:
			count += 1
	if count % 2 == 0:
		print(1)
	else:
		print(0)


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


test = int(input())
for i in range(test):
	number = int(input())
	initial = input()
	final = input()
	b = 1
	for i in range(0, number):
		if initial[i] != final[i]:
			b += 1
	print(b % 2)


t = int(input())
for i in range(t):
	n = int(input())
	S = input()
	R = input()
	b = 1
	for i in range(0, n):
		if S[i] != R[i]:
			b += 1
	print(b % 2)


T = int(input())
for _ in range(T):
	N = int(input())
	S = input()
	R = input()
	bulb = True
	for i in range(N):
		if S[i] != R[i]:
			bulb = not bulb
	print(1) if bulb else print(0)


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


for i in range(int(input())):
	x = int(input())
	a = input()
	b = input()
	c = 0
	for i in range(x):
		if a[i] != b[i]:
			c += 1
	if c % 2 == 0:
		print('1')
	else:
		print('0')


a = int(input())
for i in range(a):
	n = int(input())
	i = input()
	f = input()
	x = 1
	for j in range(n):
		if i[j] == f[j]:
			x = x
		elif i[j] != f[j]:
			x = x * -1
	if x == 1:
		print('1')
	else:
		print('0')


t = int(input())
for i in range(t):
	n = int(input())
	s = str(input())
	r = str(input())
	l = 1
	for i in range(n):
		if s[i] != r[i]:
			l += 1
	print(l % 2)


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


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


Test = int(input())
for Cases in range(Test):
	NumberofButtons = int(input())
	InitialStatus = input()
	FinalStatus = input()
	TurnOfforOn = 0
	for FinalValues in range(NumberofButtons):
		if FinalStatus[FinalValues] == InitialStatus[FinalValues]:
			TurnOfforOn += 0
		else:
			TurnOfforOn += 1
	if TurnOfforOn % 2 == 0:
		print(1)
	else:
		print(0)


for i in range(int(input())):
	n = int(input())
	lst1 = [*input()]
	lst2 = [*input()]
	num = 0
	for i in range(n):
		if lst1[i] != lst2[i]:
			num += 1
	if num % 2 == 0:
		print(1)
	else:
		print(0)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	r = input()

	def mysum(n):
		sum = 0
		for digit in str(n):
			sum += int(digit)
		return sum
	if abs(mysum(s) - mysum(r)) % 2 == 0:
		print(1)
	elif abs(mysum(s) - mysum(r)) % 2 == 1:
		print(0)


for _ in range(int(input())):
	n = int(input())
	a = str(input())
	b = str(input())
	count = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			count += 1
		else:
			pass
	if count % 2 == 0:
		print('1')
	else:
		print('0')


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


for i in range(int(input())):
	a = int(input())
	sI = input()
	sF = input()
	if (sI.count('1') - sF.count('1')) % 2 == 0:
		print('1')
	else:
		print('0')


def bulb_glow(n, s, r):
	count = 0
	for i in range(0, n):
		if s[i] != r[i]:
			count += 1
	if count % 2 == 0:
		return 1
	else:
		return 0
T = int(input())
for i in range(T):
	n = int(input())
	s = input()
	r = input()
	print(bulb_glow(n, s, r))


for _ in range(int(input())):
	a = int(input())
	l = input()
	l1 = input()
	c = 0
	for i in range(a):
		if l[i] != l1[i]:
			c += 1
	if c % 2 == 0:
		print(1)
	else:
		print(0)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	r = input()
	on = True
	for j in range(n):
		if s[j] != r[j]:
			on = not on
	if on:
		print(1)
	else:
		print(0)


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


for i in range(int(input())):
	c = 0
	N = int(input())
	S = input()
	R = input()
	for i in range(N):
		if S[i] != R[i]:
			c += 1
	if c % 2 == 0:
		print(1)
	else:
		print(0)


for _ in range(int(input())):
	x = int(input())
	s = list(input(' '))
	r = list(input(' '))
	bulb = True
	for i in range(0, x):
		if s[i] != r[i]:
			bulb = not bulb
	if bulb:
		print(1)
	else:
		print(0)


T = int(input())
for t in range(0, T):
	n = int(input())
	S = input()
	R = input()
	sl = [int(c) for c in S]
	rl = [int(c) for c in R]
	c_list = list(map(lambda x, y: abs(x - y), sl, rl))
	num_changes_of_state = sum(c_list)
	if num_changes_of_state % 2 == 0:
		bulb_state = 1
	else:
		bulb_state = 0
	print(bulb_state)


for i in range(int(input())):
	n = int(input())
	s = input()
	r = input()
	toggle = 0
	for i in range(n):
		if s[i] != r[i]:
			toggle = toggle + 1
	if toggle % 2 == 0:
		print(1)
	else:
		print(0)


for i in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	b = 0
	for j in range(n):
		if s1[j] != s2[j]:
			b += 1
	if b % 2 == 0:
		print(1)
	else:
		print(0)


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


n = int(input())
for i in range(n):
	l = int(input())
	s1 = input()
	s2 = input()
	count = 0
	for _ in range(l):
		if s1[_] == s2[_]:
			continue
		else:
			count += 1
	if count & 1:
		print(0)
	else:
		print(1)


import math

def bp():
	return int(input())

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

def ls():
	return list(map(int, input().split()))
t = int(input())
for i in range(t):
	n = bp()
	s = input()
	ss = input()
	c = 0
	for i in range(len(s)):
		if s[i] != ss[i]:
			c += 1
	print(1 if c % 2 == 0 else 0)


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	r = list(input())
	ls = [print(0) if sum([1 if s[i] != r[i] else 0 for i in range(n)]) % 2 != 0 else print(1) for j in range(1)]


for _ in range(int(input())):
	n = int(input())
	s = input()
	r = input()
	ans = 1
	for i in range(n):
		if s[i] != r[i]:
			ans += 1
	print(ans % 2)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input(' ')
	y = input(' ')
	c = 0
	for i in range(0, n):
		if x[i] != y[i]:
			c += 1
	if c % 2 == 0:
		print('1')
	else:
		print('0')


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	temp = 0
	for i in range(n):
		if s1[i] != s2[i]:
			temp += 1
	if temp % 2 == 0:
		print(1)
	else:
		print(0)


t = int(input())
for i in range(t):
	a = int(input())
	b = input()
	c = input()
	bulb = 0
	for i in range(0, a):
		if b[i] != c[i]:
			bulb = not bulb
	if bulb:
		print('0')
	else:
		print('1')


for tc in range(int(input())):
	n = int(input())
	c = 0
	In = input()
	Fn = input()
	for i in range(n):
		if In[i] == Fn[i]:
			continue
		else:
			c += 1
	if c % 2 == 0:
		print(1)
	else:
		print(0)


def solve():
	n = int(input())
	s = input()
	r = input()
	count = sum((int(x != y) for (x, y) in zip(s, r)))
	if count % 2:
		return 0
	return 1
t = int(input())
while t:
	print(solve())
	t -= 1


T = int(input())
for _ in range(T):
	N = int(input())
	initial = input()
	final = input()
	inv = 0
	if len(initial) == len(final):
		for i in range(len(initial)):
			if (initial[i] == '0' and final[i] == '1') | (initial[i] == '1' and final[i] == '0'):
				inv += 1
	if inv % 2 == 0:
		print(1)
	else:
		print(0)


for _ in range(int(input())):
	n = int(input())
	s = input()
	r = input()
	count = 'on'
	for i in range(n):
		if s[i] != r[i]:
			if count == 'on':
				count = 'off'
			elif count == 'off':
				count = 'on'
	if count == 'on':
		print('1')
	elif count == 'off':
		print('0')