Valera has got n domino pieces in a row. Each piece consists of two halves — the upper one and the lower one. Each of the halves contains a number from 1 to 6. Valera loves even integers very much, so he wants the sum of the numbers on the upper halves and the sum of the numbers on the lower halves to be even.

To do that, Valera can rotate the dominoes by 180 degrees. After the rotation the upper and the lower halves swap places. This action takes one second. Help Valera find out the minimum time he must spend rotating dominoes to make his wish come true.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 100), denoting the number of dominoes Valera has. Next n lines contain two space-separated integers x_{i}, y_{i} (1 ≤ x_{i}, y_{i} ≤ 6). Number x_{i} is initially written on the upper half of the i-th domino, y_{i} is initially written on the lower half.


-----Output-----

Print a single number — the minimum required number of seconds. If Valera can't do the task in any time, print  - 1.


-----Examples-----
Input
2
4 2
6 4

Output
0

Input
1
2 3

Output
-1

Input
3
1 4
2 3
4 4

Output
1



-----Note-----

In the first test case the sum of the numbers on the upper halves equals 10 and the sum of the numbers on the lower halves equals 6. Both numbers are even, so Valera doesn't required to do anything.

In the second sample Valera has only one piece of domino. It is written 3 on the one of its halves, therefore one of the sums will always be odd.

In the third case Valera can rotate the first piece, and after that the sum on the upper halves will be equal to 10, and the sum on the lower halves will be equal to 8.

Difficulty: EASY

Solutions:
from sys import stdin, stdout
import math
import bisect
input = stdin.readline

def print(x='', y='', end='\n'):
	if y == '':
		stdout.write(str(x) + end)
	else:
		stdout.write(str(x) + ' ' + str(y) + end)

def solve():
	n = int(input())
	(s1, s2) = (0, 0)
	flag = 0
	for i in range(n):
		(x, y) = map(int, input().split())
		s1 += x
		s2 += y
		if flag == 0:
			flag = 1 if x % 2 != y % 2 else 0
	if s1 % 2 == 0 and s2 % 2 == 0:
		print(0)
	elif s1 % 2 == s2 % 2 and flag:
		print(1)
	else:
		print(-1)
tt = 1
for __ in range(tt):
	solve()


def domino(n, arr):
	(a, b, c) = (0, 0, 0)
	for i in range(n):
		[x, y] = arr[i]
		a += x
		b += y
		if not c and (x + y) % 2:
			c = 1
	(a, b) = (a % 2, b % 2)
	return a if a == b and (a == 0 or a == c) else -1
n = int(input())
a = [map(int, input().split()) for i in range(n)]
print(domino(n, a))


n = int(input())
l = lambda i: int(i) % 2
h = [[*map(l, input().split())] for _ in ' ' * n]
s1 = sum((x[0] for x in h))
s2 = sum((x[1] for x in h))
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
	exit(0)
else:
	c1 = h.count([1, 0])
	c2 = h.count([0, 1])
	if s1 % 2 != 0 and s2 % 2 != 0 and (c1 or c2):
		print(1)
		exit(0)
print(-1)


import math, sys, os
from io import BytesIO, IOBase
mod = 10 ** 9 + 7
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 minp():
	return map(int, sys.stdin.readline().rstrip().split())

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

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

def print_list(l):
	print(' '.join(map(str, l)))
n = inp()
(up, down) = ([], [])
for i in range(n):
	(a, b) = minp()
	up.append(a)
	down.append(b)
if not sum(up) & 1 and (not sum(down) & 1):
	print(0)
	exit(0)
for i in range(n):
	if up[i] & 1 and (not down[i] & 1) or (not up[i] & 1 and down[i] & 1):
		(up[i], down[i]) = (down[i], up[i])
		break
if not sum(up) & 1 and (not sum(down) & 1):
	print(1)
else:
	print(-1)


from functools import reduce
n = int(input())
a = [tuple(map(int, input().split())) for i in range(n)]
a = list(map(lambda x: tuple(map(lambda t: t % 2, x)), a))
(sx, sy) = reduce(lambda x, y: (x[0] + y[0], x[1] + y[1]), a, (0, 0))
sx %= 2
sy %= 2
a = [x for x in a if x in ((0, 1), (1, 0))]
if sx + sy == 0:
	print(0)
elif sx + sy == 1:
	print(-1)
elif len(a) and n > 1:
	print(1)
else:
	print(-1)


n = int(input())
X = 0
Y = 0
Z = 0
for i in range(n):
	(x, y) = map(int, input().split())
	X += x
	Y += y
	if not Z and (X + Y) % 2:
		Z = 1
X = X % 2
Y = Y % 2
print(X if X == Y and (X == 0 or X == Z) else -1)


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


def scan(function):
	return map(function, input().split())
(n,) = scan(int)
l = r = 0
can = False
for i in range(n):
	(a, b) = scan(int)
	l += a
	r += b
	if a & 1 and (not b & 1):
		can = True
	if not a & 1 and b & 1:
		can = True
if not l & 1 and (not r & 1):
	print(0)
elif l & 1 and r & 1 and can:
	print(1)
else:
	print(-1)


n = int(input())
(x, y, c) = (0, 0, 0)
for i in range(n):
	(a, b) = map(int, input().split(' '))
	if a & 1:
		x = x + 1
	if b & 1:
		y = y + 1
	if a + b & 1:
		c = 1
if x & 1 == y & 1 and (x & 1 == 0 or c == 1):
	print(x & 1)
else:
	print(-1)


n = int(input())
x = []
y = []
dp = dict()

def solve(index, l):
	tupla = (index, l)
	if tupla in dp:
		return dp[tupla]
	if index >= n:
		r = sum(x) + sum(y) - l
		if l % 2 == r % 2 == 0:
			return 0
		else:
			return 99999999
	else:
		L = solve(index + 1, l + x[index])
		R = solve(index + 1, l + y[index]) + 1
		dp[tupla] = min(L, R)
		return dp[tupla]
for _ in range(n):
	(xx, yy) = map(int, input().split())
	x.append(xx)
	y.append(yy)
ans = solve(0, 0)
if ans > n:
	print(-1)
else:
	print(ans)


n = int(input())
u = 0
l = 0
change = 0
for i in range(n):
	(x, y) = [int(t) for t in input().split()]
	u += x
	l += y
	if (x + y) % 2 != 0:
		change += 1
if u % 2 == 0 and l % 2 == 0:
	print(0)
elif u % 2 != 0 and l % 2 != 0 and (change > 0):
	print(1)
else:
	print(-1)


n = int(input())
a = []
b = []
s1 = 0
s2 = 0
k = 0
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
	s1 += x
	s2 += y
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 == 0 and s2 % 2 != 0 or (s1 % 2 != 0 and s2 % 2 == 0):
	print(-1)
else:
	for i in range(n):
		if a[i] % 2 == 1 and b[i] % 2 == 0 or (a[i] % 2 == 0 and b[i] % 2 == 1):
			print(1)
			break
		k += 1
if k == n:
	print(-1)


n = int(input())
x = []
y = []
xsum = 0
ysum = 0
for i in range(n):
	s = input().split()
	x.append(int(s[0]))
	y.append(int(s[1]))
	xsum += x[i]
	ysum += y[i]
done = False
if xsum % 2 == 0 and ysum % 2 != 0 or (xsum % 2 != 0 and ysum % 2 == 0):
	print(-1)
	done = True
if xsum % 2 == 0 and ysum % 2 == 0:
	print(0)
	done = True
if not done:
	for i in range(n):
		if x[i] % 2 == 0 and y[i] % 2 != 0 or (x[i] % 2 != 0 and y[i] % 2 == 0):
			print(1)
			done = True
			break
if not done:
	print(-1)


n = int(input())
c = []
x = []
y = []
for i in range(n):
	a = [int(x) for x in input().split()]
	c.append(a)
	x.append(a[0])
	y.append(a[1])
xsum = sum(x)
ysum = sum(y)
if xsum % 2 == 0 and ysum % 2 == 0:
	print('0')
	exit()
if xsum % 2 == 0 and ysum % 2 != 0 or (xsum % 2 != 0 and ysum % 2 == 0):
	print('-1')
	exit()
for i in c:
	if i[0] % 2 == 0 and i[1] % 2 != 0 or (i[0] % 2 != 0 and i[1] % 2 == 0):
		print('1')
		exit()
print('-1')


n = eval(input())
i = 0
s1 = 0
s2 = 0
c = 0
even = 0
while i < n:
	a = input().split(' ')
	x = int(a[0])
	y = int(a[1])
	s1 = s1 + x
	s2 = s2 + y
	if x % 2 == 0 and y % 2 != 0:
		even += 1
	elif y % 2 == 0 and x % 2 != 0:
		even += 1
	i = i + 1
if s1 % 2 == 0 and s2 % 2 == 0:
	print('0')
elif s1 % 2 == 0 and s2 % 2 != 0 or (s1 % 2 != 0 and s2 % 2 == 0):
	print(-1)
elif even >= 1 and n > 1:
	print('1')
else:
	print('-1')


n = int(input())
l = []
sumup = 0
sumdown = 0
flag = 0
for i in range(n):
	l1 = [int(j) for j in input().split()]
	l.append(l1)
	sumup = sumup + l1[0]
	sumdown = sumdown + l1[1]
	if (l1[0] + l1[1]) % 2 != 0:
		flag = 1
if (sumup + sumdown) % 2 == 0:
	if sumup % 2 == 0:
		print(0)
	elif flag == 1:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
L = []
D = []
for i in range(n):
	(a, b) = map(int, input().strip().split(' '))
	L.append(a)
	D.append(b)
sumup = 0
sumdown = 0
for i in range(n):
	sumup = sumup + L[i]
	sumdown = sumdown + D[i]
k = 0
if n == 1:
	if sumup % 2 == 0 and sumdown % 2 == 0:
		print(0)
	else:
		print(-1)
elif sumup % 2 == 0 and sumdown % 2 == 0:
	print(0)
elif sumup % 2 == 1 and sumdown % 2 == 0 or (sumup % 2 == 0 and sumdown % 2 == 1):
	print(-1)
elif sumup % 2 == 1 and sumdown % 2 == 1:
	i = 0
	for i in range(len(L)):
		if L[i] % 2 == 1 and D[i] % 2 == 0 or (L[i] % 2 == 0 and D[i] % 2 == 1):
			k = 1
			break
	if k == 1:
		print(1)
	else:
		print(-1)


import sys
inf = float('inf')
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

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()
n = int(input())
sum1 = 0
sum2 = 0
count_pair = 0
for i in range(n):
	(a, b) = get_ints()
	if a % 2 == 0 and b % 2 == 1 or (a % 2 == 1 and b % 2 == 0):
		count_pair += 1
	sum1 += a
	sum2 += b
if sum1 % 2 == 0 and sum2 % 2 == 0:
	print(0)
elif sum1 % 2 == 1 and sum2 % 2 == 1:
	if count_pair > 0:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
(a, b, d) = [0] * 3
for i in range(n):
	(x, y) = map(int, input().split())
	if x % 2 == 1 and y % 2 == 1:
		d = 1 - d
	elif x % 2 == 1:
		a += 1
	elif y % 2 == 1:
		b += 1
if not d:
	if a % 2 == b % 2:
		print(a % 2)
	else:
		print(-1)
elif a % 2 == b % 2:
	if a % 2 == 1:
		print(0)
	elif a >= 2 or b >= 2:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
k = 0
left = 0
right = 0
l_k = 0
r_k = 0
for i in range(n):
	(l, r) = map(int, input().split())
	if l % 2 == 1:
		left += 1
		if r % 2 == 0:
			l_k += 1
	if r % 2 == 1:
		right += 1
		if l % 2 == 0:
			r_k += 1
if left % 2 == 0 and right % 2 == 0:
	print(0)
elif left % 2 == 1 and right % 2 == 1:
	if r_k != 0 or l_k != 0:
		print(1)
	else:
		print(-1)
elif (left + right) % 2 == 1:
	print(-1)


n = int(input())
upper = 0
lower = 0
flag = False
for i in range(n):
	tmp = [int(i) for i in input().split()]
	upper += tmp[0] % 2
	lower += tmp[1] % 2
	if tmp[0] % 2 != tmp[1] % 2:
		flag = True
if upper % 2 == 0 and lower % 2 == 0:
	print(0)
elif upper % 2 + lower % 2 == 1 or not flag:
	print(-1)
else:
	print(1)


n = int(input())
arr = []
(o2, o1, eo) = (0, 0, 0)
for i in range(n):
	(a, b) = map(int, input().split())
	arr.append([a, b])
	if a % 2 == 1:
		o1 += 1
	if b % 2 == 1:
		o2 += 1
	if a % 2 == 0 and b % 2 == 1 or (a % 2 == 1 and b % 2 == 0):
		eo += 1
if o1 % 2 == 1 and o2 % 2 == 1 and (eo != 0):
	print(1)
elif o1 % 2 == 0 and o2 % 2 == 0:
	print(0)
else:
	print(-1)


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


__copyright__ = ''
__author__ = 'Son-Huy TRAN'
__email__ = 'sonhuytran@gmail.com'
__doc__ = ''
__version__ = '1.0'

def main() -> int:
	n = int(input())
	has_even_odd_domino = False
	(sum_uppers, sum_lowers) = (0, 0)
	for _ in range(n):
		(upper, lower) = map(int, input().split())
		sum_uppers += upper
		sum_lowers += lower
		if (upper + lower) % 2 != 0:
			has_even_odd_domino = True
	if sum_lowers % 2 == 0 and sum_uppers % 2 == 0:
		print(0)
	elif sum_lowers % 2 != 0 and sum_uppers % 2 != 0:
		if has_even_odd_domino:
			print(1)
		else:
			print(-1)
	else:
		print(-1)
	return 0
exit(main())


n = int(input())
domino = []
while n > 0:
	domino.append(list(map(int, input().split())))
	n -= 1
odd_top = 0
odd_bot = 0
for i in range(len(domino)):
	if domino[i][0] % 2:
		odd_top += 1
	if domino[i][1] % 2:
		odd_bot += 1
if odd_top % 2 and odd_bot % 2:
	for i in domino:
		if sum(i) % 2:
			odd_top += 1
			odd_bot += 1
			break
elif odd_top % 2 or odd_bot % 2:
	if odd_top and odd_bot > 0:
		if odd_top % 2:
			for i in domino:
				if i[0] % 2 and (not i[1] % 2):
					odd_top += 1
					odd_bot += 1
					break
		else:
			for i in domino:
				if i[1] % 2 and (not i[0] % 2):
					odd_top += 1
					odd_bot += 1
					break
else:
	print(0)
	exit(0)
if odd_top % 2 or odd_bot % 2:
	print(-1)
else:
	print(1)


n = int(input())
s1 = 0
s2 = 0
b = False
for i in range(n):
	(x, y) = map(int, input().split())
	s1 += x
	s2 += y
	if not b and s1 % 2 != s2 % 2:
		b = True
s1 = s1 % 2
s2 = s2 % 2
if s1 == s2 == 0:
	print(0)
elif s1 == 1 == s2 and b:
	print(1)
else:
	print(-1)


n = int(input())
c = 0
sx = 0
sy = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	sx += x
	sy += y
	if x % 2 != y % 2:
		c += 1
if sx % 2 == 0 and sy % 2 == 0:
	print(0)
elif c % 2 == 0 and c > 0:
	print(1)
else:
	print(-1)


def par(x, n):
	(a, b) = (0, 0)
	for i in range(n):
		a += x[i][0]
		b += x[i][1]
	return (a % 2 == 0, b % 2 == 0)
n = int(input())
pieces = []
for i in range(n):
	pieces.append([int(j) for j in input().split()])
par2 = par(pieces, n)
if par2[0] and par2[1]:
	print(0)
elif par2[0] or par2[1]:
	print(-1)
else:
	nope = True
	for k in range(n):
		if sum(pieces[k]) % 2 != 0:
			print(1)
			nope = False
			break
	if nope:
		print(-1)


n = int(input())
sum1 = 0
sum2 = 0
b = False
for i in range(n):
	(x, y) = [int(x) for x in input().split()]
	if x % 2 != y % 2:
		b = True
	sum1 += x % 2
	sum2 += y % 2
if sum1 % 2 == 0 and sum2 % 2 == 0:
	print(0)
elif sum1 % 2 == sum2 % 2 and b:
	print(1)
else:
	print(-1)


n = int(input())
px = py = 0
od = False
for i in range(n):
	(x, y) = (int(x) for x in input().split())
	px = (px + x) % 2
	py = (py + y) % 2
	if x % 2 != y % 2:
		od = True
if px + py == 0:
	print(0)
elif px + py == 2 and od:
	print(1)
else:
	print(-1)


import sys

class Reader:

	def __init__(self, file):
		(self.tok, self.tok_length, self.tok_position) = ([], 0, 0)
		(self.lines, self.line_position) = (file.readlines(), 0)

	def next_token(self):
		if self.tok_position < self.tok_length:
			self.tok_position += 1
			return self.tok[self.tok_position - 1]
		self.tok = self.lines[self.line_position].split()
		(self.tok_length, self.tok_position) = (len(self.tok), 0)
		self.line_position += 1
		return self.next_token()

	def next_line(self):
		(self.tok, self.tok_length, self.tok_position) = ([], 0, 0)
		self.line_position += 1
		return self.lines[self.line_position - 1]

def main():
	reader = Reader(sys.stdin)
	n = int(reader.next_token())
	ls = 0
	rs = 0
	cnt = 0
	for i in range(n):
		l = int(reader.next_token())
		r = int(reader.next_token())
		ls += l
		rs += r
		if l % 2 != r % 2:
			cnt += 1
	if (ls + rs) % 2 != 0:
		print(-1)
		return
	if ls % 2 == 0 and rs % 2 == 0:
		print(0)
		return
	if cnt > 0:
		print(1)
		return
	print(-1)

def __starting_point():
	main()
__starting_point()


a = 0
b = 0
check = 0
for _ in range(int(input())):
	(p, q) = map(int, input().split())
	a += p
	b += q
	if a % 2 == 1 and b % 2 == 0 or (a % 2 == 0 and b % 2 == 1):
		check += 1
if a % 2 == b % 2 == 0:
	print(0)
elif a % 2 == b % 2 == 1 and check > 0:
	print(1)
else:
	print(-1)


n = int(input())
sup = 0
sdown = 0
flag = 0
for i in range(n):
	a = input().split()
	sup += int(a[0])
	sdown += int(a[1])
	if not int(a[0]) % 2 == int(a[1]) % 2:
		flag = 1
if sup % 2 == 0 and sdown % 2 == 0:
	print('0')
if not sup % 2 == sdown % 2:
	print('-1')
if sup % 2 == 1 and sdown % 2 == 1 and flag and (n > 1):
	print('1')
if sup % 2 == 1 and sdown % 2 == 1 and (not (flag and n > 1)):
	print('-1')


from sys import stdin, stdout
import math
n = int(stdin.readline())
lx = []
ly = []
for i in range(n):
	(x, y) = map(int, stdin.readline().split())
	lx.append(x)
	ly.append(y)
if sum(lx) % 2 == 0 and sum(ly) % 2 == 0:
	print(0)
elif sum(lx) % 2 == 0 or sum(ly) % 2 == 0:
	print(-1)
else:
	f = 0
	for i in range(n):
		if lx[i] % 2 == 0 and ly[i] % 2 != 0 or (lx[i] % 2 != 0 and ly[i] % 2 == 0):
			f = 1
			break
	if f == 1:
		print(1)
	else:
		print(-1)


import sys
n = int(next(sys.stdin))
has_even_odd_pair = False
(sx, sy) = (0, 0)
for line in sys.stdin:
	(x, y) = [int(x) for x in line.split()]
	if (x + y) % 2 == 1:
		has_even_odd_pair = True
	sx += x
	sy += y
if sx % 2 == 0 and sy % 2 == 0:
	print(0)
elif sx % 2 == 1 and sy % 2 == 1:
	if has_even_odd_pair:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
(a, b, c) = [0] * 3
for i in range(n):
	(x, y) = [int(v) for v in input().split()]
	if x % 2 == 0:
		if y % 2 == 1:
			b = 1 - b
			c = 1
	else:
		a = 1 - a
		if y % 2 == 0:
			c = 1
		else:
			b = 1 - b
if a == 0 and b == 0:
	print(0)
elif a == 1 and b == 1 and (c == 1):
	print(1)
else:
	print(-1)


from functools import reduce
n = int(input(' '))
u = []
l = []
s1 = 0
s2 = 0
for i in range(n):
	d = list(map(int, input().split(' ')))
	if sum(d) % 2 == 1:
		u.append(int(d[0]))
		l.append(int(d[1]))
	s1 += int(d[0])
	s2 += int(d[1])
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 == 1 and s2 % 2 == 1 and (len(u) > 0):
	print(1)
else:
	print(-1)


n = int(input())
ls = []
sum_upper = 0
sum_lower = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	ls.append((x, y))
	sum_upper += x
	sum_lower += y
count = 0
if sum_upper % 2 == 0 and sum_lower % 2 == 0:
	print(0)
elif sum_upper % 2 != 0 and sum_lower % 2 != 0:
	cond = False
	for i in range(n):
		if ls[i][0] % 2 != ls[i][1] % 2:
			cond = True
	if cond == True:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
odds = evens = double_odds = 0
left = right = 0
for i in range(n):
	(l, r) = map(int, input().split())
	if l % 2 == 0 and r % 2 == 0:
		evens += 1
	elif l % 2 == 1 and r % 2 == 1:
		double_odds += 1
	else:
		odds += 1
	left += l
	right += r
if left % 2 == 0 and right % 2 == 0:
	print(0)
elif left % 2 != right % 2:
	print(-1)
elif double_odds % 2 == 0 or (double_odds % 2 == 1 and odds % 2 == 0 and (odds > 1)):
	print(1)
else:
	print(-1)


size = int(input().strip())
up = []
lo = []
for i in range(size):
	(u, l) = map(int, input().strip().split())
	up.append(u)
	lo.append(l)
i = 0
(s1, s2) = (0, 0)
(uc, lc) = (set(), set())
while i < size:
	if up[i] & 1 and (not lo[i] & 1):
		uc.add(i)
	elif not up[i] & 1 and lo[i] & 1:
		lc.add(i)
	s1 += up[i]
	s2 += lo[i]
	i += 1
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 and s2 % 2:
	if len(lc) or len(uc):
		print(1)
	else:
		print(-1)
else:
	print(-1)


import sys
input = sys.stdin.buffer.readline
n = int(input())
l = 0
r = 0
swap = 0
while n:
	n -= 1
	(a, b) = map(int, input().split())
	if a % 2 == 0 and b % 2 == 1:
		swap += 1
	elif b % 2 == 0 and a % 2 == 1:
		swap += 1
	l += a
	r += b
if l % 2 == 0 and r % 2 == 0:
	print('0')
elif l % 2 == 1 and r % 2 == 1:
	if swap > 1:
		print('1')
	else:
		print('-1')
else:
	print('-1')


n = int(input())
mat = []
for i in range(n):
	(x, y) = map(int, input().split())
	mat.append([x, y])
upper = 0
lower = 0
for i in range(n):
	upper += mat[i][0]
for i in range(n):
	lower += mat[i][1]
if upper % 2 == 0 and lower % 2 == 0:
	print(0)
elif upper % 2 == 0 and lower % 2 == 1:
	print(-1)
elif upper % 2 == 1 and lower % 2 == 0:
	print(-1)
else:
	flag = 0
	for i in range(n):
		if mat[i][0] % 2 == 0 and mat[i][1] % 2 == 1:
			flag = 1
			break
		elif mat[i][0] % 2 == 1 and mat[i][1] % 2 == 0:
			flag = 1
			break
		else:
			continue
	if flag == 1:
		print(1)
	else:
		print(-1)


n = int(input())
u = []
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	u.append(a)
	l.append(b)
	u1 = list(u)
	l1 = list(l)
t = 0
for i in range(n):
	if sum(u1) % 2 == 0 and sum(l1) % 2 == 0:
		print(t)
		exit()
	elif u[i] % 2 != 0 and l[i] % 2 != 0:
		continue
	elif u[i] % 2 == 0 and l[i] % 2 == 0:
		continue
	else:
		x = u[i]
		y = l[i]
		u1 = list(u)
		l1 = list(l)
		u1.pop(i)
		u1.insert(i, y)
		l1.pop(i)
		l1.insert(i, x)
		t = t + 1
print('-1')


t = int(input())
i = 0
l = []
u = []
ans = False
for _ in range(t):
	n = list(map(int, input().split()))
	l.append(n[1])
	u.append(n[0])
	if n[1] % 2 != n[0] % 2:
		ans = True
if sum(l) % 2 == 0 and sum(u) % 2 == 0:
	print('0')
elif sum(l) % 2 != sum(u) % 2:
	print('-1')
elif ans:
	print('1')
else:
	print('-1')


n = int(input())
count = -1
A = [0] * 3
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if a % 2 == 1 and b % 2 == 1:
		A[0] += 1
	elif a % 2 == 1:
		A[1] += 1
	elif b % 2 == 1:
		A[2] += 1
if A[0] % 2 == 0 and (A[1] + A[2]) % 2 == 0:
	print(A[1] % 2)
elif (A[1] + A[2]) % 2 == 0 and A[1] + A[2] >= 2:
	if A[1] % 2 == A[2] % 2 == 1:
		print(0)
	else:
		print(1)
else:
	print(-1)


n = int(input())
c1 = c2 = 0
mat = []
for i in range(n):
	(x, y) = map(int, input().split(' '))
	c1 += x
	c2 += y
	mat.append([x, y])
c1 = c1 % 2
c2 = c2 % 2
if c1 == 0 and c2 == 0:
	print('0')
elif n == 1 or (c1 == 1) ^ (c2 == 1):
	print('-1')
else:
	for i in range(n):
		if (mat[i][0] % 2 == 1) ^ (mat[i][1] % 2 == 1):
			print(1)
			exit()
	print('-1')


n = int(input())
upper = []
lower = []
a = -1
for i in range(n):
	(x, y) = map(int, input().split())
	upper.append(x)
	lower.append(y)
if sum(upper) % 2 == 0 and sum(lower) % 2 == 0:
	print(0)
elif sum(upper) % 2 == 0 and sum(lower) % 2 == 1 or (sum(upper) % 2 == 1 and sum(lower) % 2 == 0):
	print(-1)
elif sum(upper) % 2 == 1 and sum(lower) % 2 == 1:
	for i in range(len(lower)):
		if lower[i] % 2 == 0 and upper[i] % 2 == 1 or (lower[i] % 2 == 1 and upper[i] % 2 == 0):
			print(1)
			a = 1
			break
	if a == -1:
		print(-1)


n = int(input())
(A, B, C) = (0, 0, 0)
for i in range(n):
	(a, b) = map(int, input().split())
	A += a
	B += b
	if a % 2 != b % 2:
		C = 1
if A % 2 == 0 and B % 2 == 0:
	print(0)
elif A % 2 == 1 and B % 2 == 1 and C:
	print(1)
else:
	print(-1)


N = int(input())
Check = False
Sum = 0
(Sum_l, Sum_r) = (0, 0)
for i in range(N):
	(x, y) = list(map(int, input().split()))
	Sum_l += x
	Sum_r += y
	Sum += x + y
	if (x % 2 + y % 2) % 2:
		Check = True
if Sum % 2:
	print(-1)
elif Sum_l % 2:
	if not Check:
		print(-1)
	else:
		print(1)
elif Sum_l % 2 == 0:
	print(0)


n = int(input())
x = 0
y = 0
a = []
for i in range(n):
	a.append([int(x) for x in input().split()])
	x += a[-1][0]
	y += a[-1][1]
if x % 2 == 0 and y % 2 == 0:
	print(0)
elif x % 2 != 0 and y % 2 != 0:
	for i in a:
		if i[0] % 2 != i[1] % 2:
			print(1)
			exit()
	else:
		print(-1)
else:
	print(-1)


def main():
	n = int(input())
	upper = []
	lower = []
	for i in range(n):
		(x, y) = [int(x) for x in input().split()]
		upper.append(x)
		lower.append(y)
	if sum(upper) % 2 == 0 and sum(lower) % 2 == 0:
		print(0)
		return 0
	elif sum(upper) % 2 != 0 and sum(lower) % 2 != 0:
		for i in range(n):
			if upper[i] % 2 == 0 and lower[i] % 2 != 0 or (upper[i] % 2 != 0 and lower[i] % 2 == 0):
				print(1)
				return 0
		print(-1)
	else:
		print(-1)
main()


dom = []
(su, sd) = (0, 0)
tot = 0
for _ in range(int(input())):
	dom.append(list(map(int, input().split())))
	su += dom[-1][0]
	sd += dom[-1][1]
	tot += sum(dom[-1])
if tot % 2 != 0:
	print(-1)
elif su % 2 != sd % 2:
	print(-1)
else:
	if su == sd and su % 2 == 0 and (sd % 2 == 0):
		print(0)
		exit()
	if su % 2 == 0 and sd % 2 == 0:
		print(0)
		exit()
	f = 0
	for i in dom:
		if i[0] % 2 != i[1] % 2:
			f = 1
			break
	if f:
		print(1)
	else:
		print(-1)


n = int(input())
count1 = 0
count2 = 0
odd = False
for i in range(n):
	(num1, num2) = map(int, input().split())
	count1 = (count1 + num1) % 2
	count2 = (count2 + num2) % 2
	if num1 % 2 + num2 % 2 == 1:
		odd = True
if count1 + count2 == 0:
	print(0)
elif count1 + count2 == 2:
	if odd:
		print(1)
	else:
		print(-1)
else:
	print(-1)


a = int(input())
sum1 = 0
sum2 = 0
k = 0
i = 0
while i < a:
	c = list(map(int, input().split()))
	if c[0] % 2 == 0 and c[1] % 2 == 1 or (c[0] % 2 == 1 and c[1] % 2 == 0):
		k = 1
	sum1 += c[0]
	sum2 += c[1]
	i += 1
if sum1 % 2 == 1 and sum2 % 2 == 1:
	if k == 0:
		print(-1)
	else:
		print(1)
elif sum1 % 2 == 1 and sum2 % 2 == 0 or (sum1 % 2 == 0 and sum2 % 2 == 1):
	print(-1)
else:
	print(0)


n = int(input())
x = [None] * n
y = [None] * n
for i in range(n):
	(x[i], y[i]) = map(int, input().split())
sx = sum(x)
sy = sum(y)
ans = -1
if sx % 2 == 0 and sy % 2 == 0:
	ans = 0
elif sx % 2 == 1 and sy % 2 == 1:
	for i in range(n):
		if x[i] % 2 != y[i] % 2:
			ans = 1
print(ans)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = int(input())
l = []
l1 = []
t = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a % 2 + b % 2 == 1:
		t = 1
	l += [a]
	l1 += [b]
if sum(l1) % 2 == 0 and sum(l) % 2 == 0:
	print('0')
elif sum(l1) % 2 + sum(l) % 2 == 1:
	print('-1')
elif t == 0 or n == 1:
	print('-1')
else:
	print('1')


n = int(input())
x = []
y = []
co1 = int(0)
co2 = int(0)
count = [0, 0]
for i in range(n):
	(k, l) = map(int, input().split())
	x.append(k)
	y.append(l)
a = x[:]
b = y[:]
f1 = int(0)
f2 = int(0)
if sum(x) % 2 == 0 and sum(y) % 2 == 0:
	print(0)
elif sum(x) % 2 == 0 and sum(y) % 2 != 0 or (sum(y) % 2 == 0 and sum(x) % 2 != 0):
	print(-1)
else:
	for i in range(n):
		if x[i] % 2 != 0 and y[i] % 2 == 0:
			temp = x[i]
			x[i] = y[i]
			y[i] = temp
			count[0] += 1
		if sum(x) % 2 == 0 and sum(y) % 2 == 0:
			f1 = 1
			break
	for i in range(n):
		if b[i] % 2 != 0 and a[i] % 2 == 0:
			temp = a[i]
			a[i] = b[i]
			b[i] = temp
			count[1] += 1
		if sum(a) % 2 == 0 and sum(b) % 2 == 0:
			f2 = 1
			break
	if f1 == 1 and f2 == 1:
		print(min(count))
	elif f1 == 1:
		print(count[0])
	elif f2 == 1:
		print(count[1])
	else:
		print(-1)


import sys
inf = float('inf')

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()
n = int(input())
sum1 = sum2 = 0
eo_pair = 0
for i in range(n):
	(x, y) = get_ints()
	if x & 1 and (not y & 1) or (y & 1 and (not x & 1)):
		eo_pair += 1
	sum1 += x
	sum2 += y
if sum1 % 2 == 0 and sum2 % 2 == 0:
	print(0)
elif sum1 & 1 and sum2 & 1:
	if eo_pair >= 1:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
swappable = False
leftsum = 0
rightsum = 0
for _ in range(n):
	(a, b) = [int(x) for x in input().split()]
	leftsum += a
	rightsum += b
	if swappable == False and (leftsum - rightsum) % 2 == 1:
		swappable = True
c = leftsum % 2
d = rightsum % 2
if c + d == 0:
	print(0)
elif c + d == 2 and swappable:
	print(1)
else:
	print(-1)


n = int(input())
(s1, s2) = (0, 0)
c = 0
for i in range(n):
	(x, y) = (int(i) for i in input().split())
	s1 += x
	s2 += y
	if x % 2 == 1 and y % 2 == 0 or (x % 2 == 0 and y % 2 == 1):
		c = 1
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 == 1 and s2 % 2 == 1:
	if c == 1:
		print(1)
	else:
		print(-1)
else:
	print(-1)


le = 0
re = 0
lo = 0
ro = 0
arr = []
for _ in range(int(input())):
	arr2 = []
	(a, b) = list(map(int, input().split()))
	if a % 2 == 0:
		le += 1
		arr2.append('e')
	else:
		lo += 1
		arr2.append('o')
	if b % 2 == 0:
		re += 1
		arr2.append('e')
	else:
		ro += 1
		arr2.append('o')
	arr.append(arr2)
if lo % 2 != 0 and ro % 2 == 0 or (lo % 2 == 0 and ro % 2 != 0):
	print(-1)
elif lo % 2 != 0 and ro % 2 != 0:
	if ['e', 'o'] in arr or ['o', 'e'] in arr:
		print(1)
	else:
		print(-1)
else:
	print(0)


def domino():
	n = int(input())
	l = []
	for i in range(n):
		(x, y) = map(int, input().split())
		l.append((x, y))
	countox = countoy = counteo = 0
	for i in range(n):
		if l[i][0] % 2 != 0:
			countox = countox + 1
		if l[i][1] % 2 != 0:
			countoy = countoy + 1
		if (l[i][0] + l[i][1]) % 2 != 0:
			counteo += 1
	if countox % 2 != 0 and countoy % 2 != 0 and (counteo > 0):
		print(1)
		return
	if countox % 2 == 0 and countoy % 2 == 0:
		print(0)
		return
	else:
		print(-1)
domino()


def domino(n):
	mark = -1
	(u, l) = (0, 0)
	for i in range(n):
		(a, b) = list(map(int, input().split()))
		if mark < 0 and (a + b) % 2 > 0:
			mark = 1
		u = (u + a) % 2
		l = (l + b) % 2
	if u == 0 and l == 0:
		return 0
	elif (u + l) % 2 == 0:
		return mark
	else:
		return -1

def main():
	n = int(input())
	print(domino(n))
main()


import sys
from math import sqrt
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())
n = int(input())
numOfDiff = 0
sumX = 0
sumY = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if x % 2 == 0 and y % 2 != 0 or (x % 2 != 0 and y % 2 == 0):
		numOfDiff += 1
	sumX += x
	sumY += y
if sumX % 2 == 0 and sumY % 2 == 0:
	print(0)
elif sumX % 2 == 0 and sumY % 2 != 0 or (sumX % 2 != 0 and sumY % 2 == 0):
	print(-1)
elif numOfDiff == 0:
	print(-1)
else:
	print(1)


n = int(input())
upper = []
lower = []
for j in range(n):
	(x, y) = map(int, input().split())
	upper.append(x)
	lower.append(y)
flag = False
l = sum(lower)
u = sum(upper)
if l % 2 == 0 and u % 2 == 0:
	print(0)
	flag = True
else:
	for i in range(n):
		if (u - upper[i] + lower[i]) % 2 == 0 and (l - lower[i] + upper[i]) % 2 == 0:
			print(1)
			flag = True
			break
if not flag:
	print(-1)


n = int(input())
upperSum = 0
lowerSum = 0
specialDomino = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	upperSum += y
	lowerSum += x
	if x % 2 == 0 and y % 2 != 0:
		specialDomino += 1
	elif x % 2 != 0 and y % 2 == 0:
		specialDomino += 1
if upperSum % 2 == 0 and lowerSum % 2 == 0:
	print(0)
elif upperSum % 2 != 0 and lowerSum % 2 != 0 and (specialDomino >= 1):
	print(1)
else:
	print(-1)


n = int(input())
left_odds = right_odds = both_odds = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	if x % 2 and y % 2:
		both_odds += 1
	else:
		if x % 2:
			left_odds += 1
		if y % 2:
			right_odds += 1
if (left_odds + both_odds) % 2 == (right_odds + both_odds) % 2 == 0:
	print(0)
elif left_odds and (left_odds - 1 + both_odds) % 2 == (right_odds + 1 + both_odds) % 2 == 0:
	print(1)
elif right_odds and (left_odds + 1 + both_odds) % 2 == (right_odds - 1 + both_odds) % 2 == 0:
	print(1)
else:
	print(-1)


import sys, math, bisect
inf = float('inf')
mod = 998244353

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

def gcd(a, b):
	return int(math.gcd(a, b))

def tobinary(n):
	return bin(n)[2:]

def binarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def lowerBound(a, x):
	i = bisect.bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def upperBound(a, x):
	i = bisect.bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def primesInRange(n):
	ans = []
	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
	for p in range(2, n + 1):
		if prime[p]:
			ans.append(p)
	return ans

def primeFactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n = n // i
	if n > 2:
		factors.append(n)
	return factors
from collections import deque, defaultdict, Counter
import heapq
for _ in range(1):
	n = int(input())
	upper = []
	lower = []
	for i in range(n):
		i = list(map(int, input().split()))
		upper.append(i[0])
		lower.append(i[1])
	sumup = sum(upper)
	sumlow = sum(lower)
	if sumup % 2 == 0 and sumlow % 2 == 0:
		print(0)
	else:
		cnt = 0
		flag = False
		for i in range(n):
			if upper[i] % 2 != lower[i] % 2:
				sumup -= upper[i]
				sumup += lower[i]
				sumlow -= lower[i]
				sumlow += upper[i]
				(upper[i], lower[i]) = (lower[i], upper[i])
				cnt += 1
				if sumup % 2 == 0 and sumlow % 2 == 0:
					flag = True
					break
		if n == 1:
			if upper[0] % 2 == 1 or lower[0] % 2 == 1:
				print(-1)
			else:
				print(0)
		elif not flag:
			print(-1)
		else:
			print(cnt)


n = int(input())
ue = 0
de = 0
u = []
d = []
flag = False
for _ in range(n):
	(u_, d_) = map(int, input().split())
	if u_ % 2 != d_ % 2:
		flag = True
	u.append(u_)
	d.append(d_)
s1 = sum(u)
s2 = sum(d)
if s1 % 2 == 0 and s2 % 2 == 0:
	print('0')
elif s1 % 2 == s2 % 2 and flag:
	print(1)
else:
	print('-1')


n = int(input())
x = []
y = []
for i in range(n):
	(a, b) = map(int, input().strip().split(' '))
	x.append(a)
	y.append(b)
sumY = sum(y)
sumX = sum(x)
if sumX % 2 == 0 and sumY % 2 == 0:
	print(0)
else:
	flag = 0
	for i in range(n):
		if (sumX - x[i] + y[i]) % 2 == 0 and (sumY - y[i] + x[i]) % 2 == 0:
			print(1)
			flag = 1
			break
	if flag == 0:
		print(-1)


N = int(input())
A = [tuple((int(j) for j in input().split())) for i in range(N)]
(S1, S2) = (0, 0)
for (a, b) in A:
	S1 += a
	S2 += b
if S1 % 2 == 0 and S2 % 2 == 0:
	print(0)
	return
if (S1 % 2 == 0) ^ (S2 % 2 == 0):
	print(-1)
	return
for (a, b) in A:
	if (a % 2 == 0) ^ (b % 2 == 0):
		print(1)
		return
print(-1)


n = int(input())
up = []
down = []
for i in range(n):
	(x, y) = map(int, input().split())
	up.append(x)
	down.append(y)
if sum(up) % 2 == 0 and sum(down) % 2 == 0:
	print(0)
elif (sum(up) + sum(down)) % 2 == 1:
	print(-1)
else:
	chk = False
	for i in range(n):
		if (up[i] % 2 + down[i]) % 2 == 1:
			print(1)
			chk = True
			break
	if not chk:
		print(-1)


z = input
mod = 10 ** 9 + 7
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

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:
			return 0
	return 1
z = input
mod = 10 ** 9 + 7
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

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:
			return 0
	return 1
n = int(z())
l1 = []
l2 = []
for _ in range(n):
	(x, y) = map(int, z().split())
	l1.append(x)
	l2.append(y)
t1 = sum(l1)
t2 = sum(l2)
if t1 % 2 == 0 and t2 % 2 == 0:
	print(0)
	exit()
for (i, j) in zip(l1, l2):
	if (t1 - i + j) % 2 == 0 and (t2 - j + i) % 2 == 0:
		print(1)
		exit(0)
print(-1)


n = int(input())
(b, t, o) = (0, 0, 0)
for _ in range(n):
	(x, y) = map(int, input().split())
	b += x
	t += y
	if x % 2 == 1 and y % 2 == 0 or (x % 2 == 0 and y % 2 == 1):
		o += 1
if b % 2 == t % 2 == 0:
	print(0)
elif b % 2 == t % 2 == 1 and o > 0:
	print(1)
else:
	print(-1)


x = int(input())
c = 0
a = []
for i in range(x):
	a = a + list(map(int, input().split()))
sum1 = sum(a[0:2 * x:2])
sum2 = sum(a[1:2 * x:2])
if sum1 % 2 == 0 and sum2 % 2 == 0:
	print('0')
elif sum1 % 2 == 1 and sum2 % 2 == 1:
	for i in range(0, 2 * x, 2):
		if a[i] % 2 != a[i + 1] % 2:
			print('1')
			c += 1
			break
	if c == 0:
		print('-1')
else:
	print('-1')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
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 main():
	n = I()
	a = [LI() for _ in range(n)]
	f = 0
	b = c = 0
	for (d, e) in a:
		b += d
		b %= 2
		c += e
		c %= 2
		if (d + e) % 2 == 1:
			f = 1
	if b == c:
		if b == 0:
			return 0
		if f:
			return 1
	return -1
print(main())


def solution():
	n = int(input())
	odd = 0
	even = 0
	upsm = 0
	dwnsm = 0
	atleastone = False
	for i in range(n):
		(f, s, t, fr) = (False, False, False, False)
		(u, d) = map(int, input().split())
		if u % 2 == 0:
			even += 1
			f = True
		else:
			odd += 1
			s = True
		if d % 2 == 0:
			even += 1
			t = True
		else:
			odd += 1
			fr = True
		if f and fr or (s and t):
			atleastone = True
		upsm += u
		dwnsm += d
	if upsm % 2 == 0 and dwnsm % 2 == 0:
		print(0)
		return
	if upsm % 2 != 0 and dwnsm % 2 != 0:
		if even % 2 == 0 and odd % 2 == 0 and atleastone:
			print(1)
			return
		else:
			print(-1)
			return
	print(-1)
	return
solution()


n = int(input())
uo = {}
uc = 0
lo = {}
lc = 0
for i in range(n):
	(x, y) = map(int, input().split(' '))
	if x % 2:
		uo[i] = 1
		uc += 1
	if y % 2:
		lo[i] = 1
		lc += 1
if uc % 2 and lc % 2:
	works = 0
	for x in uo:
		if x not in lo:
			works = 1
	for x in lo:
		if x not in uo:
			works = 1
	if works:
		print(1)
	else:
		print(-1)
elif uc % 2 == 0 and lc % 2 == 0:
	print(0)
else:
	print(-1)


import math
Flag = True
Row_of_bones = []
n = int(input())
for i in range(n):
	x = list(map(int, input().split()))
	Row_of_bones.append(x)

def check_parity() -> bool:
	(upp, low) = (0, 0)
	for i in Row_of_bones:
		upp += i[0]
		low += i[1]
	if upp % 2 == 0 and low % 2 == 0:
		return True
	else:
		return False
count = 0
for x in Row_of_bones:
	if check_parity():
		print(count)
		Flag = False
		break
	elif x[0] % 2 == 0 and x[1] % 2 != 0 or (x[0] % 2 != 0 and x[1] % 2 == 0):
		(x[0], x[1]) = (x[1], x[0])
		count = 1
if Flag == True:
	print(-1)


def readln():
	return tuple(map(int, input().split()))
(n,) = readln()
a = b = c = 0
for _ in range(n):
	(x, y) = readln()
	a += x
	b += y
	c += x % 2 ^ y % 2
if a % 2 == 0 and b % 2 == 0:
	print(0)
elif a % 2 == b % 2 and c:
	print(1)
else:
	print(-1)


n = int(input().strip())
(a, b) = ([0] * n, [0] * n)
(sumA, sumB) = (0, 0)
for i in range(n):
	(a[i], b[i]) = map(int, input().strip().split())
	sumA += a[i]
	sumB += b[i]
if (sumA % 2 or sumB % 2) == 0:
	print(0)
elif sumA % 2 ^ sumB % 2:
	print(-1)
elif any((a[i] % 2 ^ b[i] % 2 for i in range(n))):
	print(1)
else:
	print(-1)


n = int(input())
x = [0] * n
y = [0] * n
z = [0] * n
s = 0
t = 0
for i in range(0, n):
	(a, b) = map(int, input().split())
	x[i] = a
	y[i] = b
	z[i] = (a + b) % 2
	s = s + a
	t = t + b
if (s + t) % 2 == 1:
	print(-1)
elif s % 2 == 0 and t % 2 == 0:
	print(0)
elif z.count(1) == 0:
	print(-1)
else:
	print(1)


n = int(input())
sx = 0
sy = 0
l = []
while n > 0:
	n -= 1
	(x, y) = map(int, input().split())
	sx += x
	sy += y
	l.append([x, y])
if sx % 2 == 0 and sy % 2 == 0:
	print(0)
elif sx % 2 == 0 and sy % 2 != 0 or (sx % 2 != 0 and sy % 2 == 0):
	print(-1)
else:
	f = 0
	for i in l:
		if (i[0] + i[1]) % 2 != 0:
			f = 1
	if f == 0:
		print(-1)
	else:
		print(1)


from sys import stdin
n = int(stdin.readline().rstrip())
(s1, s2) = (0, 0)
f = 0
while n > 0:
	(a, b) = map(int, stdin.readline().split())
	if a % 2 != b % 2:
		f = 1
	s1 += a
	s2 += b
	n -= 1
if s1 % 2 != s2 % 2:
	print(-1)
elif s1 % 2 == 1:
	if f == 1:
		print(f)
	else:
		print(-1)
else:
	print(0)


n = int(input())
(x, y, z) = [0] * 3
for i in range(n):
	(a, b) = input().split()
	x += int(a)
	y += int(b)
	z += (int(a) + int(b)) % 2
print((-1, (0, (-1, 1)[z > 0])[y % 2])[x % 2 == y % 2])


def domino(n_int: int, x_and_y_list: list) -> int:
	upper_odd_count = 0
	lower_odd_count = 0
	for i in range(n_int):
		if x_and_y_list[i][0] % 2 == 1:
			upper_odd_count += 1
		if x_and_y_list[i][1] % 2 == 1:
			lower_odd_count += 1
	if upper_odd_count % 2 == 0 and lower_odd_count % 2 == 0:
		return 0
	elif upper_odd_count % 2 != lower_odd_count % 2:
		return -1
	else:
		for i in range(n_int):
			if x_and_y_list[i][0] % 2 != x_and_y_list[i][1] % 2:
				return 1
		return -1
n = int(input())
x_and_y = [tuple(map(int, input().split())) for i in range(n)]
print(domino(n, x_and_y))


n = int(input())
l = r = m = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	if x % 2 and y % 2:
		l += 1
		r += 1
	elif x % 2:
		l += 1
		m += 1
	elif y % 2:
		r += 1
		m += 1
if l % 2 and r % 2 and m:
	print(1)
elif l % 2 == 0 and r % 2 == 0:
	print(0)
else:
	print(-1)


n = int(input())
p = 0
q = 0
r = 0
for i in range(n):
	x = list(map(int, input().split()))
	a = x[0]
	b = x[1]
	if a % 2 == 0 and b % 2 != 0:
		p = p + 1
	elif a % 2 != 0 and b % 2 == 0:
		q = q + 1
	elif a % 2 != 0 and b % 2 != 0:
		r = r + 1
if (p + q) % 2 != 0:
	print(-1)
elif r == 0:
	if p % 2 == 0 and q % 2 == 0:
		print(0)
	else:
		print(1)
elif p % 2 == 0 and q % 2 == 0:
	if r % 2 == 0:
		print(0)
	elif p == 0 and q == 0:
		print(-1)
	else:
		print(1)
elif r % 2 != 0:
	print(0)
else:
	print(1)


from functools import reduce
dominoes = [list(map(lambda x: int(x) % 2, input().split())) for x in range(int(input()))]
(temp1, temp2) = (reduce(lambda a, x: (a + x[0]) % 2, dominoes, 0), reduce(lambda a, x: (a + x[1]) % 2, dominoes, 0))
if temp1 == temp2 == 0:
	print(0)
elif temp1 == temp2 == 1 and ([1, 0] in dominoes or [0, 1] in dominoes):
	print(1)
else:
	print(-1)


def __starting_point():
	n = int(input())
	topodds = 0
	bottomodds = 0
	flipabble = False
	for _ in range(n):
		(top, bottom) = list(map(int, input().split()))
		if not flipabble and (top + bottom) % 2 != 0:
			flipabble = True
		topodds += 0 if top % 2 == 0 else 1
		bottomodds += 0 if bottom % 2 == 0 else 1
	if (topodds + bottomodds) % 2 != 0:
		print(-1)
	elif topodds % 2 != 0 or bottomodds % 2 != 0:
		print(1 if flipabble else -1)
	else:
		print(0)
__starting_point()


n = int(input())
a = []
s1 = s2 = 0
for i in range(n):
	a.append([int(i) for i in input().split()])
	s1 += a[i][0]
	s2 += a[i][1]
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 != s2 % 2:
	print(-1)
else:
	for i in a:
		if i[0] % 2 != i[1] % 2:
			print(1)
			exit(0)
	print(-1)


n = int(input())
array = []
suml = 0
sumr = 0
flag = 0
for i in range(n):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	suml += x
	sumr += y
	if (x % 2 == 0) ^ (y % 2 == 0):
		flag = 1
if suml % 2 == 0 and sumr % 2 == 0:
	print(0)
elif suml % 2 != 0 and sumr % 2 != 0:
	if flag == 1:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
top = []
bot = []
for i in range(n):
	(x, y) = map(int, input().split())
	top.append(x)
	bot.append(y)
if sum(top) % 2 == 0 and sum(bot) % 2 == 0:
	print(0)
elif sum(top) % 2 != 0 and sum(bot) % 2 != 0 and (len(top) > 1):
	for i in range(len(top)):
		if top[i] % 2 == 0 and bot[i] % 2 != 0 or (top[i] % 2 != 0 and bot[i] % 2 == 0):
			print(1)
			exit()
	else:
		print(-1)
else:
	print(-1)


n = int(input())
listo = []
s1 = 0
s2 = 0
listo2 = []
for _ in range(n):
	u = [int(i) % 2 for i in input().split()]
	listo.append(u)
	if u[0] != u[1]:
		listo2.append([u[0], u[1]])
	s1 += u[0]
	s2 += u[1]
s1 %= 2
s2 %= 2
if s1 == 0 and s2 == 0:
	print(0)
elif s1 != s2:
	print(-1)
elif s1 == 1 and s2 == 1:
	if len(listo2) == 0:
		print(-1)
	else:
		print(1)


n = int(input())
cnt = 0
suma = sumb = 0
for i in range(0, n):
	(a, b) = map(int, input().split())
	if a % 2 != b % 2:
		cnt += 1
	(suma, sumb) = (suma + a, sumb + b)
if suma % 2 == 0 and sumb % 2 == 0:
	print(0)
elif suma % 2 != sumb % 2:
	print(-1)
elif cnt > 0:
	print(1)
else:
	print(-1)


(s, ss) = (0, 0)
c = 0
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(s, ss) = ((s + x) % 2, (ss + y) % 2)
	if (x + y) % 2 == 1:
		c += 1
if s == 0 and ss == 0:
	print(0)
elif s == 1 and ss == 1:
	if c >= 1:
		print(1)
	else:
		print(-1)
else:
	print(-1)


t = int(input())
top = 0
bottom = 0
t1 = []
b1 = []
for _ in range(t):
	(x, y) = [int(i) for i in input().split()]
	top += x
	bottom += y
	t1.append(x)
	b1.append(y)
if top % 2 == 0 or bottom % 2 == 0:
	if top % 2 == 0 and bottom % 2 == 0:
		print(0)
	else:
		print(-1)
else:
	flag = 0
	for i in range(t):
		if t1[i] % 2 == 0 and b1[i] % 2 != 0 or (t1[i] % 2 != 0 and b1[i] % 2 == 0):
			flag = 1
	if flag == 1:
		print(1)
	else:
		print(-1)


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')
import math

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
(s1, s2) = (0, 0)
flag = 0
for t in range(int(input())):
	(x, y) = list(map(int, input().split()))
	s1 += x
	s2 += y
	if x % 2 != y % 2:
		flag = 1
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 != s2 % 2:
	print(-1)
elif flag == 1:
	print(1)
else:
	print(-1)


n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
if sum(a) % 2 == 0 and sum(b) % 2 == 0:
	print(0)
elif sum(a) % 2 and sum(b) % 2:
	x = 0
	for i in range(n):
		if a[i] % 2 and b[i] % 2 == 0 or (a[i] % 2 == 0 and b[i] % 2):
			x = 1
			break
	if x:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
flag = 0
flag2 = 0
up = [0] * n
down = [0] * n
for i in range(n):
	(up[i], down[i]) = map(int, input().split())
if up == down:
	flag = 1
sum1 = sum(up)
sum2 = sum(down)
for k in range(n):
	if up[k] % 2 + down[k] % 2 == 1:
		flag2 = 1
		break
if n == 1 and (sum1 % 2 == 1 or sum2 % 2 == 1):
	print('-1')
elif sum1 % 2 == 0 and sum2 % 2 == 0:
	print('0')
elif (sum1 % 2 == 1 and sum2 % 2 == 1) and flag == 0 and (flag2 == 1):
	print('1')
else:
	print('-1')


n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
up_downs = list(zip(*l))
up_down = [list(i) for i in up_downs]
odd = 0
if sum(up_down[0]) % 2 == 0 and sum(up_down[1]) % 2 == 0:
	print(odd)
	exit()
else:
	for i in range(len(up_down[0])):
		if up_down[0][i] % 2 != 0 and up_down[1][i] % 2 == 0:
			odd += 1
			(up_down[0][i], up_down[1][i]) = (up_down[1][i], up_down[0][i])
			if sum(up_down[0]) % 2 == 0 and sum(up_down[1]) % 2 == 0:
				print(odd)
				exit()
		elif up_down[0][i] % 2 == 0 and up_down[1][i] % 2 != 0:
			odd += 1
			(up_down[0][i], up_down[1][i]) = (up_down[1][i], up_down[0][i])
			if sum(up_down[0]) % 2 == 0 and sum(up_down[1]) % 2 == 0:
				print(odd)
				exit()
print(-1)


n = int(input())
arr_upper = []
arr_lower = []
for i in range(n):
	(a, b) = map(int, input().split())
	arr_upper.append(a)
	arr_lower.append(b)
(summ1, summ2) = (sum(arr_upper), sum(arr_lower))
if summ1 % 2 == 0 and summ2 % 2 == 0:
	print(0)
elif summ1 % 2 != summ2 % 2:
	print(-1)
else:
	for i in range(n):
		if arr_upper[i] % 2 != arr_lower[i] % 2:
			print(1)
			exit()
	print(-1)


from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt, gcd

def time_t():
	print('Current date and time: ', datetime.datetime.now())
	print('Current year: ', datetime.date.today().strftime('%Y'))
	print('Month of year: ', datetime.date.today().strftime('%B'))
	print('Week number of the year: ', datetime.date.today().strftime('%W'))
	print('Weekday of the week: ', datetime.date.today().strftime('%w'))
	print('Day of year: ', datetime.date.today().strftime('%j'))
	print('Day of the month : ', datetime.date.today().strftime('%d'))
	print('Day of week: ', datetime.date.today().strftime('%A'))

def ip():
	return int(input())

def sip():
	return input()

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

def mips():
	return map(str, input().split())

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

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst

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

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def prime(n):
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
n = ip()
up = 0
down = 0
count = 0
while n:
	n -= 1
	(a, b) = mip()
	if a % 2 != 0 and b % 2 == 0:
		count += 1
	elif a % 2 == 0 and b % 2 != 0:
		count += 1
	up += a
	down += b
if up % 2 == 0 and down % 2 == 0:
	print(0)
elif up % 2 == 0 and down % 2 != 0:
	print(-1)
elif up % 2 != 0 and down % 2 == 0:
	print(-1)
elif count > 0:
	print(1)
else:
	print(-1)


n = int(input().strip())
dominos = []
for i in range(n):
	domino = list(map(int, input().strip().split()))
	dominos.append(domino)
t_sum = 0
b_sum = 0
for i in range(n):
	t_sum += dominos[i][0]
	b_sum += dominos[i][1]
if t_sum % 2 == 0 and b_sum % 2 == 0:
	print(0)
elif t_sum % 2 == 1 and b_sum % 2 == 0:
	print(-1)
elif t_sum % 2 == 0 and b_sum % 2 == 1:
	print(-1)
else:
	valid = False
	for i in dominos:
		if (i[0] + i[1]) % 2 == 1:
			valid = True
			break
	if valid:
		print(1)
	else:
		print(-1)


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


c = []
d = []
count_c = 0
count_d = 0
count = 0
f = 0
n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	c.append(a)
	d.append(b)
for i in range(n):
	if c[i] % 2 != 0:
		count_c += 1
	if d[i] % 2 != 0:
		count_d += 1
if count_c % 2 == 0 and count_d % 2 == 0:
	print(0)
elif count_c % 2 != 0 and count_d % 2 != 0:
	for i in range(n):
		if c[i] % 2 != 0 and d[i] % 2 != 0:
			f += 1
		if f == count_c and f == count_d:
			print(-1)
			break
	else:
		print(1)
elif count_c % 2 == 0 and count_d % 2 != 0 or (count_c % 2 != 0 and count_d % 2 == 0):
	print(-1)


n = int(input())
r = [list(map(int, input().split())) for _ in range(n)]
(s1, s2) = (0, 0)
for i in range(n):
	s1 += r[i][0]
	s2 += r[i][1]
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 != s2 % 2:
	print(-1)
else:
	print(1 if any(((r[i][0] + r[i][1]) % 2 == 1 for i in range(n))) else -1)


t = int(input())
c = [0, 0, 0, 0]
for _ in range(t):
	(a, b) = input().split(' ')
	a = int(a) % 2
	b = int(b) % 2
	c[a + 2 * b] += 1
if (c[1] + c[3]) % 2 == 0 and (c[2] + c[3]) % 2 == 0:
	print(0)
elif abs(c[2] - c[1]) % 2 == 0:
	if c[1] == 0 and c[2] == 0:
		print(-1)
	else:
		print(1)
else:
	print(-1)


n = int(input())
countUp = 0
countDown = 0
countBoth = 0
for i in range(n):
	a = [int(i) for i in input().split()]
	if a[0] % 2 == 1 and a[1] % 2 == 1:
		countBoth += 1
	elif a[0] % 2 == 1:
		countUp += 1
	elif a[1] % 2 == 1:
		countDown += 1
countBoth = countBoth % 2
if countBoth == 1:
	if countUp > 0:
		if countUp % 2 == 0:
			countUp = 2
		else:
			countUp = 1
	if countDown > 0:
		if countDown % 2 == 0:
			countDown = 2
		else:
			countDown = 1
	if countUp == 1 and countDown == 1:
		print(0)
	elif countUp == 2 and countDown % 2 == 0:
		print(1)
	elif countUp % 2 == 0 and countDown == 2:
		print(1)
	else:
		print(-1)
else:
	countUp = countUp % 2
	countDown = countDown % 2
	if countUp == 0 and countDown == 0:
		print(0)
	elif countUp == 1 and countDown == 1:
		print(1)
	else:
		print(-1)


n = int(input())
f = [0] * n
t = [0] * n
u = 0
l = 0
dif = False
for i in range(n):
	(f[i], t[i]) = input().split()
	f[i] = int(f[i])
	t[i] = int(t[i])
	u += f[i]
	l += t[i]
	if f[i] % 2 != t[i] % 2:
		dif = True
if n == 1 and dif:
	print(-1)
elif u % 2 == 0 and l % 2 == 0:
	print(0)
elif dif and u % 2 == 1 and (l % 2 == 1):
	print(1)
else:
	print(-1)


def domino(n, m):
	a = sum(n)
	b = sum(m)
	count = 0
	if a % 2 == 0 and b % 2 == 0:
		print(0)
	elif a % 2 == 0 and b % 2 != 0:
		print(-1)
	elif b % 2 == 0 and a % 2 != 0:
		print(-1)
	elif a % 2 != 0 and b % 2 != 0 and (len(n) == 1):
		print(-1)
	else:
		for i in range(len(n)):
			if n[i] % 2 == 0 and m[i] % 2 != 0:
				count += 1
			elif m[i] % 2 == 0 and n[i] % 2 != 0:
				count += 1
			else:
				continue
		if count > 0:
			print(1)
		else:
			print(-1)
a = input()
n = []
m = []
for i in range(int(a)):
	(x, y) = input().split()
	n.append(int(x))
	m.append(int(y))
domino(n, m)


n = int(input())
x = []
y = []
pe = []
po = []
sumx = 0
sumy = 0
for i in range(n):
	(x1, y1) = map(int, input().split())
	x.append(x1)
	y.append(y1)
	sumx += x1
	sumy += y1
	if x1 % 2 == 0:
		pe.append(i)
	else:
		po.append(i)
lene = len(pe)
leno = len(po)
if leno % 2 == 0:
	if sumy % 2 == 0:
		print('0')
	else:
		print('-1')
else:
	for i in po:
		if y[i] % 2 == 0:
			sumy -= y[i]
			sumx -= x[i]
			sumx += y[i]
			sumy += x[i]
			break
	if sumx % 2 == 0 and sumy % 2 == 0:
		print('1')
	else:
		for i in pe:
			if y[i] % 2 != 0:
				sumy -= y[i]
				sumx -= x[i]
				sumx += y[i]
				sumy += x[i]
				break
		if sumx % 2 == 0 and sumy % 2 == 0:
			print('1')
		else:
			print('-1')


n = int(input())
x_arr = []
y_arr = []
for i in range(n):
	(x, y) = map(int, input().split())
	x_arr.append(x)
	y_arr.append(y)
if sum(x_arr) % 2 == 0 and sum(y_arr) % 2 == 0:
	print(0)
elif sum(x_arr) % 2 == 0 and sum(y_arr) % 2 != 0 or (sum(x_arr) % 2 != 0 and sum(y_arr) % 2 == 0):
	print(-1)
else:
	ans = [1, -1]
	f = 1
	for i in range(n):
		if x_arr[i] % 2 == 0 and y_arr[i] % 2 != 0 or (x_arr[i] % 2 != 0 and y_arr[i] % 2 == 0):
			f = 0
			break
	print(ans[f])


c = 0
n = int(input())
(o1, o2) = (0, 0)
(l, w) = ([], [])
for i in range(n):
	(x, y) = map(int, input().split())
	l.append(x)
	w.append(y)
	if x % 2:
		o1 += 1
	if y % 2:
		o2 += 1
if o1 % 2 and o2 % 2:
	for i in range(n):
		if l[i] % 2 == 0 and w[i] % 2:
			print(1)
			break
		elif l[i] % 2 and w[i] % 2 == 0:
			print(1)
			break
	else:
		print(-1)
elif o1 % 2 == 0 and o2 % 2 == 0:
	print(0)
else:
	print(-1)


n = int(input())
flag = 0
sumu = 0
suml = 0
for i in range(n):
	iarr = list(map(int, input().split()))
	sumu += iarr[0]
	suml += iarr[1]
	if iarr[0] % 2 != iarr[1] % 2:
		flag = 1
pu = sumu % 2
pd = suml % 2
if pu == pd == 0:
	print(0)
elif pu == pd == 1 and flag == 1:
	print(1)
else:
	print(-1)


def main():
	X = []
	Y = []
	sumx = 0
	sumy = 0
	tm = 0
	n = int(input())
	for i in range(n):
		(x, y) = map(int, input().split())
		sumx += x
		sumy += y
		X.append(x)
		Y.append(y)
	if sumx % 2 == sumy % 2 != 0:
		for i in range(n):
			if X[i] % 2 != 0 and Y[i] % 2 == 0:
				sumx = sumx - X[i] + Y[i]
				sumy = sumy - Y[i] + X[i]
				print(1)
				break
		if sumx % 2 != 0 and sumy % 2 != 0:
			for i in range(n):
				if Y[i] % 2 != 0 and X[i] % 2 == 0:
					sumx = sumx + X[i] - Y[i]
					sumy = sumy + Y[i] - X[i]
					print(1)
					break
		if sumx % 2 != 0 and sumy % 2 != 0:
			print(-1)
	elif sumx % 2 == sumy % 2 == 0:
		print(0)
	else:
		print(-1)
main()


n = int(input())
x = [[], []]

def odd_count(l: list) -> int:
	count = 0
	for j in range(n):
		if l[j] % 2 != 0:
			count += 1
	return count
for i in range(n):
	(a, b) = map(int, input().split())
	x[0].append(a)
	x[1].append(b)
o0 = odd_count(x[0])
e0 = len(x[0]) - o0
o1 = odd_count(x[1])
e1 = len(x[1]) - o1
if o0 % 2 == 0 and o1 % 2 == 0:
	print(0)
elif abs(o0 - o1) % 2 == 0 and (e0 > 0 or e1 > 0):
	count = 0
	for i in range(n):
		if (x[0][i] + x[1][i]) % 2 == 0:
			count += 1
	if count == len(x[0]):
		print(-1)
	else:
		print(1)
else:
	print(-1)


n = int(input())
top = []
bottom = []
sum_top = 0
sum_bottom = 0
possible = False
for i in range(n):
	(j, k) = map(int, input().split(' '))
	top.append(j)
	bottom.append(k)
	sum_top += j
	sum_bottom += k
	if j % 2 != k % 2:
		possible = True
if sum_bottom % 2 == 0 and sum_top % 2 == 0:
	print(0)
elif sum_bottom % 2 != sum_top % 2 or not possible:
	print(-1)
else:
	print(1)


import sys
import itertools
import math
import collections
from collections import Counter
input = sys.stdin.readline

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 * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def divs(n, start=1):
	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 ceil(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
n = ii()
t = u = b = 0
for _ in range(n):
	(x, y) = mi()
	u += x
	b += y
	if x % 2 != y % 2:
		t += 1
u %= 2
b %= 2
if u != b or (u and t == 0):
	print(-1)
elif u == b == 0:
	print(0)
else:
	print(1)


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


n = int(input())
upper = []
lower = []
for i in range(n):
	(a, b) = map(int, input().split())
	upper.append(a)
	lower.append(b)
if sum(upper) % 2 == 0 and sum(lower) % 2 == 0:
	print(0)
else:
	boo = True
	for i in range(n):
		(upper[i], lower[i]) = (lower[i], upper[i])
		if sum(upper) % 2 == 0 and sum(lower) % 2 == 0:
			print(1)
			boo = False
			break
		(upper[i], lower[i]) = (lower[i], upper[i])
	if boo:
		print(-1)


n = int(input())
d = []
for i in range(0, n):
	tmp = input().split()
	(x, y) = (tmp[0], tmp[1])
	d.append((x, y))
xSum = 0
ySum = 0
for (x, y) in d:
	xSum += int(x)
	ySum += int(y)
if xSum % 2 == 0 and ySum % 2 == 0:
	print(0)
elif (xSum + ySum) % 2 == 1:
	print(-1)
else:
	result = False
	for (x, y) in d:
		if (int(x) + int(y)) % 2 == 1:
			result = True
	if result == True:
		print(1)
	else:
		print(-1)


def main():
	n = int(input())
	sumtop = 0
	sumbottom = 0
	flippable = False
	for i in range(n):
		st = input()
		arr = st.split(' ')
		a = int(arr[0])
		b = int(arr[1])
		sumtop += a
		sumbottom += b
		if a % 2 + b % 2 == 1:
			flippable = True
	if sumtop % 2 == 0 and sumbottom % 2 == 0:
		print(0)
	elif sumtop % 2 + sumbottom % 2 == 1:
		print(-1)
	elif flippable:
		print(1)
	else:
		print(-1)

def __starting_point():
	main()
__starting_point()


a = int(input())
v = []
n = []
x = 0
l = 0
r = 0
sum1 = 0
sum2 = 0
for i in range(a):
	(l, r) = map(int, input().split())
	v.append(l)
	n.append(r)
sum1 = sum(v)
sum2 = sum(n)
if sum1 % 2 == 1 and sum2 % 2 == 0 or (sum2 % 2 == 1 and sum2 % 1 == 0):
	x = -1
if sum1 % 2 == 1 and sum2 % 2 == 1:
	x = -1
	for i in range(a):
		if v[i] % 2 != n[i] % 2:
			x = 1
			break
print(x)


import os
import sys

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 lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	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
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

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

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

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

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
from collections import OrderedDict
n = iinp()
xarr = []
yarr = []
for i in range(n):
	(x, y) = nninp()
	xarr.append(x)
	yarr.append(y)
s1 = sum(xarr)
s2 = sum(yarr)
if s1 % 2 == 0 and s2 % 2 == 0:
	p(0)
elif s1 % 2 == 1 and s2 % 2 == 1:
	f = 0
	for i in range(n):
		if xarr[i] % 2 != yarr[i] % 2:
			f = 1
			break
	if f == 1:
		p(1)
	else:
		p(-1)
else:
	p(-1)


n = int(input())
x = []
y = []
xodd = 0
yodd = 0
for i in range(n):
	(a, b) = map(int, input().split())
	x.append(a % 2)
	y.append(b % 2)
	if x[i] % 2:
		xodd += 1
	if y[i] % 2:
		yodd += 1
if xodd % 2 ^ yodd % 2:
	print(-1)
elif xodd % 2 & yodd % 2:
	flag = 1
	for i in range(n):
		if x[i] ^ y[i]:
			print(1)
			flag = 0
			break
	if flag:
		print(-1)
else:
	print(0)


import sys
num_dices = int(input())
dice = []
for x in range(num_dices):
	dice.append(list(map(int, input().split())))
if num_dices == 1:
	if dice[0][0] % 2 != 0 and dice[0][1] % 2 != 0:
		print('-1')
		sys.exit(0)
left_odd = 0
left_eve = 0
right_odd = 0
right_eve = 0
odd_even_switches = 0
even_odd_switches = 0
for x in dice:
	if x[0] % 2 == 0:
		left_eve += 1
	else:
		left_odd += 1
	if x[1] % 2 == 0:
		right_eve += 1
	else:
		right_odd += 1
	if x[0] % 2 == 0 and x[1] % 2 != 0:
		even_odd_switches += 1
	if x[0] % 2 != 0 and x[1] % 2 == 0:
		odd_even_switches += 1
total = 0
switches = even_odd_switches + odd_even_switches
if right_odd % 2 != 0 and left_odd % 2 != 0 and (switches != 0):
	print('1')
	sys.exit(0)
if right_odd % 2 == 0 and left_odd % 2 != 0 or (right_odd % 2 != 0 and left_odd % 2 == 0):
	print('-1')
	sys.exit(0)
if right_odd % 2 == 0 and left_odd % 2 == 0:
	print('0')
	sys.exit(0)
if right_odd % 2 != 0 and left_odd % 2 != 0 and (switches == 0):
	print('-1')
	sys.exit(0)


n = int(input())
(x, y, p) = ([], [], [])
for i in range(n):
	(l1, l2) = input().split()
	if int(l1) % 2 == 0:
		x.append(0)
	else:
		x.append(1)
	if int(l2) % 2 == 0:
		x.append(0)
	else:
		y.append(1)
	if int(l1) % 2 != 0 and int(l2) % 2 != 0:
		p.append(i)
(s1, s2) = (sum(x), sum(y))
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif len(p) == s1 and len(p) == s2 and (len(p) != 0):
	print(-1)
elif s1 % 2 == 0 and s2 % 2 != 0 or (s1 % 2 != 0 and s2 % 2 == 0):
	print(-1)
elif len(p) % 2 == 1:
	if (s1 - len(p)) % 2 == 0 and (s2 - len(p)) % 2 == 0:
		print(1)
	else:
		print(-1)
else:
	print(1)


n = int(input())
a = []
b = []
eo = oe = False
for _ in range(n):
	(a1, b1) = map(int, input().split())
	a.append(a1)
	b.append(b1)
	if a1 % 2 == 0 and b1 % 2 != 0:
		eo = True
	elif a1 % 2 != 0 and b1 % 2 == 0:
		oe = True
asum = sum(a)
bsum = sum(b)
if asum % 2 != bsum % 2:
	print(-1)
elif asum % 2 == 0:
	print(0)
elif eo or oe:
	print(1)
else:
	print(-1)


n = int(input())
upper = []
lower = []
for i in range(n):
	temp = input().split(' ')
	upper.append(int(temp[0]))
	lower.append(int(temp[1]))
keep1 = sum(upper)
keep2 = sum(lower)
if keep1 % 2 == 0 and keep2 % 2 == 0:
	print(0)
if keep1 % 2 != 0 and keep2 % 2 == 0 or (keep1 % 2 == 0 and keep2 % 2 != 0):
	print(-1)
if keep1 % 2 != 0 and keep2 % 2 != 0:
	dec = False
	for i in range(n):
		if upper[i] % 2 != 0 and lower[i] % 2 == 0 or (upper[i] % 2 == 0 and lower[i] % 2 != 0):
			print(1)
			dec = True
			break
	if not dec:
		print(-1)


n = int(input())
(eo, sl, su) = (0, 0, 0)
for i in range(0, n):
	(a, b) = map(int, input().split(' '))
	sl = sl + b
	su = su + a
	if a % 2 == 0 and b % 2 == 1 or (a % 2 == 1 and b % 2 == 0):
		eo = 1
if sl % 2 == 0 and su % 2 == 0:
	print(0)
elif sl % 2 == 1 and su % 2 == 1:
	if eo:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
pc = []
upper = 0
lower = 0
time = 0
for i in range(n):
	a = list(map(int, input().split()))
	pc.append(a)
for i in range(len(pc)):
	upper = 0
	lower = 0
	for j in pc:
		upper += j[0]
		lower += j[1]
	if upper % 2 == 0 and lower % 2 == 0:
		break
	else:
		(pc[i][1], pc[i][0]) = (pc[i][0], pc[i][1])
		time += 1
if upper % 2 == 0 and lower % 2 == 0:
	if time >= 1:
		print(1)
	else:
		print(0)
else:
	print(-1)


n = int(input())
x = []
y = []
for i in range(n):
	(a, b) = map(int, input().split())
	x.append(a)
	y.append(b)
f = 0
count = 0

def ch(x, y):
	if sum(x) % 2 == 0:
		if sum(y) % 2 == 0:
			return 1
	else:
		return 0
if ch(x, y):
	print(0)
else:
	f = 0
	for i in range(n):
		f = 0
		(x[i], y[i]) = (y[i], x[i])
		count += 1
		if ch(x, y):
			print(1)
			f = 1
			break
		else:
			continue
	if f == 0:
		print(-1)


sum1 = 0
sum2 = 0
count = 0
n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	sum1 += a
	sum2 += b
	if (a + b) % 2 == 1:
		count = 1
if sum1 % 2 == 0 and sum2 % 2 == 0:
	print(0)
elif (sum1 + sum2) % 2 == 0 and n > 1 and (count == 1):
	print(1)
else:
	print(-1)


n = int(input())
(arr_a, arr_b) = ([], [])
for _ in range(n):
	(a, b) = map(int, input().split())
	arr_a.append(a)
	arr_b.append(b)
if sum(arr_a) % 2 + sum(arr_b) % 2 == 0:
	print(0)
	exit()
for i in range(n):
	(arr_a[i], arr_b[i]) = (arr_b[i], arr_a[i])
	if sum(arr_a) % 2 + sum(arr_b) % 2 == 0:
		print(1)
		exit()
print(-1)


n = int(input())
upp = []
low = []
for i in range(0, n):
	lis = list(map(int, input().split()))
	upp.append(lis[0])
	low.append(lis[1])
sup = sum(upp)
slo = sum(low)
if sup % 2 == 0:
	if slo % 2 == 0:
		print(0)
	else:
		print(-1)
elif slo % 2 == 0:
	print(-1)
else:
	flag = 0
	for i in range(0, n):
		if (upp[i] - low[i]) % 2 == 0:
			continue
		else:
			flag = 1
			break
	if flag == 1:
		print(1)
	else:
		print(-1)


import sys
n = int(input())
s1 = 0
s2 = 0
n10 = 0
n01 = 0
for _ in range(n):
	(x, y) = map(int, sys.stdin.readline().split())
	s1 += x
	s2 += y
	if x % 2 == 1:
		if y % 2 == 0:
			n10 += 1
	elif y % 2 == 1:
		n01 += 1
if (s1 + s2) % 2 == 1:
	print(-1)
elif s1 % 2 == 0:
	print(0)
elif n10 + n01 > 0:
	print(1)
else:
	print(-1)


n = int(input())
s = False
l = 0
r = 0
if n > 1:
	for i in range(n):
		(x, y) = map(int, input().split())
		if x % 2 + y % 2 == 1:
			s = True
		l += x
		r += y
	if l % 2 == 0 and r % 2 == 0:
		print(0)
	elif l % 2 == 1 and r % 2 == 1 and s:
		print(1)
	else:
		print(-1)
else:
	(x, y) = map(int, input().split())
	if x % 2 == 0 and y % 2 == 0:
		print(0)
	else:
		print(-1)


import sys
from math import *
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
ls = lambda : list(input().strip())
from collections import defaultdict as df
import heapq
infinite = float('inf')
n = int(input())
u = 0
d = 0
l = []
for i in range(n):
	(a, b) = RI()
	l.append((a, b))
	u += a
	d += b
if u % 2 == 0 and d % 2 == 0:
	print(0)
elif u % 2 == 0:
	print(-1)
elif d % 2 == 0:
	print(-1)
else:
	f = 0
	for i in range(n):
		if l[i][0] % 2 == 0 and l[i][1] % 2 == 1 or (l[i][0] % 2 == 1 and l[i][1] % 2 == 0):
			print('1')
			f = 1
			break
	if f == 0:
		print('-1')


n = int(input())
parity = 0
(s1, s2) = (0, 0)
for _ in range(n):
	(a, b) = map(int, input().split())
	s1 += a
	s2 += b
	if a % 2 == 0 and b % 2 != 0:
		parity += 1
	if a % 2 != 0 and b % 2 == 0:
		parity += 1
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 != 0 and s2 % 2 != 0:
	if parity:
		print(1)
	else:
		print(-1)
else:
	print(-1)


(f, l, m, s, t, k) = (1, [], [], 0, 0, 0)
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(a)
	m.append(b)
	s += a
	t += b
if s % 2 + t % 2 == 1:
	f = 0
elif s % 2 == 1 and t % 2 == 1:
	for i in range(n):
		if l[i] % 2 == 1 and m[i] % 2 == 0 or (l[i] % 2 == 0 and m[i] % 2 == 1):
			k = 1
			break
	else:
		f = 0
print(k if f == 1 else -1)


n = int(input())
(upper, lower) = ([], [])
arr = [list(map(int, input().split())) for i in range(n)]
par = 0
(sum_upper, sum_lower) = (0, 0)
for i in arr:
	sum_upper += i[0]
	sum_lower += i[1]
	if i[0] % 2 == 0 and i[1] % 2 != 0:
		par += 1
	elif i[0] % 2 != 0 and i[1] % 2 == 0:
		par += 1
if sum_upper % 2 == 0 and sum_lower % 2 == 0:
	print(0)
elif sum_upper % 2 == 0 and sum_lower % 2 != 0:
	print(-1)
elif sum_lower % 2 == 0 and sum_upper % 2 != 0:
	print(-1)
elif sum_lower % 2 != 0 and sum_upper % 2 != 0:
	if par > 0:
		print(1)
	else:
		print(-1)


n = int(input().strip())
ll = []
p1 = 0
p0 = 0
for i in range(n):
	ll.append(list(map(int, input().split())))
	if ll[-1][0] % 2 == 1:
		p0 += 1
	if ll[-1][1] % 2 == 1:
		p1 += 1
if p0 % 2 == 0 and p1 % 2 == 1:
	print(-1)
elif p0 % 2 == 1 and p1 % 2 == 0:
	print(-1)
elif p0 % 2 == 0 and p1 % 2 == 0:
	print(0)
elif p0 != p1:
	print(1)
else:
	t = False
	for i in range(n):
		if ll[i][0] % 2 == 0 and ll[i][1] % 2 == 1:
			t = True
			break
		if ll[i][1] % 2 == 0 and ll[i][0] % 2 == 1:
			t = True
			break
	print(1 if t == True else -1)


def main():
	numberOfDomino = int(input())
	aboveSum = 0
	belowSum = 0
	canSwap = False
	for i in range(numberOfDomino):
		(a, b) = input().split(sep=' ')
		(a, b) = (int(a) % 2, int(b) % 2)
		aboveSum = aboveSum + a
		belowSum = belowSum + b
		if a != b:
			canSwap = True
	aboveSum = aboveSum % 2
	belowSum = belowSum % 2
	if aboveSum == 0 and belowSum == 0:
		print(0)
	elif aboveSum == 1 and belowSum == 1 and canSwap:
		print(1)
	else:
		print(-1)
main()


n = int(input())
pieces = []
for _ in range(n):
	pieces.append([int(x) for x in input().split()])
s1 = sum([x[0] for x in pieces])
s2 = sum([x[1] for x in pieces])
exist_dif_odd = False
for p in pieces:
	if p[0] % 2 != p[1] % 2:
		exist_dif_odd = True
if s2 % 2 == 0 and s1 % 2 == 0:
	print(0)
elif s1 % 2 != 0 and s2 % 2 != 0 and exist_dif_odd:
	print(1)
elif s1 % 2 != 0 and s2 % 2 != 0 and (not exist_dif_odd):
	print(-1)
else:
	print(-1)


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


n = int(input())
numOfDiff = 0
sumX = 0
sumY = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if x % 2 == 0 and y % 2 != 0 or (x % 2 != 0 and y % 2 == 0):
		numOfDiff += 1
	sumX += x
	sumY += y
if sumX % 2 == 0 and sumY % 2 == 0:
	print(0)
elif sumX % 2 == 0 and sumY % 2 != 0 or (sumX % 2 != 0 and sumY % 2 == 0):
	print(-1)
elif numOfDiff == 0:
	print(-1)
else:
	print(1)


n = int(input())
sumu = 0
suml = 0
s = n
diff = 0
while n > 0:
	i = input().split()
	(x, y) = (int(i[0]), int(i[1]))
	sumu += x
	suml += y
	if x % 2 == 0 and y % 2 == 1 or (x % 2 == 1 and y % 2 == 0):
		diff = 1
	n -= 1
if sumu % 2 == 0 and suml % 2 == 0:
	print(0)
elif sumu % 2 == 1 and suml % 2 == 1 and (diff == 1):
	print(1)
else:
	print(-1)


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
u = 0
l = 0
d = 0
for i in range(n):
	u = u + a[i][0]
	l = l + a[i][1]
	if a[i][0] % 2 != a[i][1] % 2:
		d = d + 1
if u % 2 == 0 and l % 2 == 0:
	print(0)
elif u % 2 == 1 and l % 2 == 1:
	if d > 0:
		print(1)
	else:
		print(-1)
else:
	print(-1)


u = []
l = []
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	u.append(x)
	l.append(y)
if sum(u) % 2 == 0 and sum(l) % 2 == 0:
	print(0)
else:
	if sum(u) % 2 == 0 and sum(l) % 2 != 0 or (sum(u) % 2 != 0 and sum(l) % 2 == 0):
		print(-1)
	if sum(u) % 2 != 0 and sum(l) % 2 != 0:
		k = 0
		for i in range(n):
			if (u[i] + l[i]) % 2 != 0:
				k += 1
		if k > 0:
			print(1)
		else:
			print(-1)


n = int(input())
sx = 0
sy = 0
odd = 0
for i in range(n):
	(a, b) = map(int, input().split())
	sx += a
	sy += b
	if a % 2 != b % 2:
		odd = 1
if sx % 2 == sy % 2 == 0:
	print(0)
elif sx % 2 != sy % 2:
	print(-1)
elif odd:
	print(1)
else:
	print(-1)


def main():
	n = int(input())
	(X, Y) = ([], [])
	for i in range(n):
		(x, y) = map(int, input().split())
		X.append(x)
		Y.append(y)
	(s_X, s_Y) = (sum(X), sum(Y))
	if s_X % 2 == 0 and s_Y % 2 == 0:
		return 0
	elif s_X % 2 ^ s_Y % 2:
		return -1
	else:
		for i in range(n):
			if X[i] % 2 ^ Y[i] % 2:
				return 1
		return -1
print(main())


def function(n, nums):
	odd_pair_count = 0
	odd_count1 = 0
	odd_count2 = 0
	for j in range(n):
		condition = True
		if nums[j][0] % 2 != 0 and nums[j][-1] % 2 != 0:
			odd_pair_count += 1
		if nums[j][0] % 2 != 0:
			odd_count1 += 1
		if nums[j][-1] % 2 != 0:
			odd_count2 += 1
	if odd_count1 + odd_count2 == 0:
		return 0
	if (odd_count1 + odd_count2) % 2 != 0:
		return -1
	if (odd_count1 + odd_count2) % 2 == 0:
		if odd_pair_count * 2 - (odd_count1 + odd_count2) == 0:
			if odd_pair_count % 2 == 0:
				return 0
			return -1
		if odd_count1 == 0 or odd_count2 == 0:
			return 0
		if odd_count1 % 2 == 0:
			return 0
		return 1
n = int(input())
nums = []
for i in range(n):
	nums.append(list(map(int, input().rstrip().split())))
print(function(n, nums))


a = int(input())
list = []
for i in range(a):
	(x, y) = map(int, input().split())
	list.append([x, y])
for i in range(a):
	(sum1, sum2) = (0, 0)
	for j in range(a):
		(sum1, sum2) = (sum1 + list[j][0], sum2 + list[j][1])
	if sum1 % 2 == 0 and sum2 % 2 == 0:
		print(0)
		exit()
for i in range(a):
	list[i].reverse()
	(sum1, sum2) = (0, 0)
	for j in range(a):
		(sum1, sum2) = (sum1 + list[j][0], sum2 + list[j][1])
	if sum1 % 2 == 0 and sum2 % 2 == 0:
		print(1)
		quit()
	else:
		list[i].reverse()
		continue
print(-1)


l1 = []
l2 = []
n = int(input())
for __ in range(n):
	(x, y) = map(int, input().split())
	l1.append(x)
	l2.append(y)
if sum(l1) % 2 == 0 and sum(l2) % 2 == 0:
	print(0)
elif sum(l1) % 2 != 0 and sum(l2) % 2 != 0 and (n != 1):
	c = -1
	for (i, j) in zip(l1, l2):
		if abs(i - j) % 2 != 0:
			c += 2
			break
	print(c)
else:
	print(-1)


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split(' '))))
Summ1 = Summ2 = 0
for i in range(n):
	Summ1 += a[i][0]
	Summ2 += a[i][1]
F = False
if Summ1 // 2 == Summ1 / 2 and Summ2 // 2 == Summ2 / 2:
	print(0)
	F = True
if Summ1 // 2 != Summ1 / 2 and Summ2 // 2 != Summ2 / 2 and (n != 1):
	for i in range(n):
		if a[i][1] // 2 != a[i][1] / 2 and a[i][0] // 2 == a[i][0] / 2 or (a[i][0] // 2 != a[i][0] / 2 and a[i][1] // 2 == a[i][1] / 2):
			print(1)
			F = True
			break
if F == False:
	print(-1)


n = int(input())
(up, down) = (list(), list())
for _ in range(n):
	(a, b) = map(int, input().split())
	up.append(a)
	down.append(b)
if sum(up) % 2 == 0 and sum(down) % 2 == 0:
	print(0)
if sum(up) % 2 == 0 and sum(down) % 2 == 1:
	print(-1)
if sum(up) % 2 == 1 and sum(down) % 2 == 0:
	print(-1)
if sum(up) % 2 == 1 and sum(down) % 2 == 1:
	ans = False
	for i in range(n):
		if up[i] % 2 == 0 and down[i] % 2 == 1 or (down[i] % 2 == 0 and up[i] % 2 == 1):
			ans = True
			break
	if ans:
		print(1)
	else:
		print(-1)


n = int(input())
i = 0
l1 = []
l2 = []
while i < n:
	s = list(map(int, input().split()))
	s[0] = s[0] % 2
	s[1] = s[1] % 2
	l1.append(s[0])
	l2.append(s[1])
	i += 1
up = l1.count(1) % 2
down = l2.count(1) % 2
if up == 0 and down == 0:
	print(0)
elif up + down == 1:
	print(-1)
elif l1 == l2:
	print(-1)
else:
	print(1)


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

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

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

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

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

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

def wr(arr):
	return '\n'.join(map(str, arr))

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

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
n = ii()
tx = ty = 0
f = False
for i in range(n):
	(x, y) = mi()
	if (x + y) % 2 == 1:
		f = True
	tx += x
	ty += y
if tx % 2 == 0 and ty % 2 == 0:
	print(0)
elif f and (tx + ty) % 2 == 0:
	print(1)
else:
	print(-1)


def main():
	n = int(input())
	(sum1, sum2) = (0, 0)
	exist = False
	for i in range(n):
		N = input().split()
		(n1, n2) = (int(N[0]), int(N[1]))
		if n1 % 2 == 1 and n2 % 2 == 0 or (n2 % 2 == 1 and n1 % 2 == 0):
			exist = True
		sum1 += n1
		sum2 += n2
	if sum1 % 2 == 0 and sum2 % 2 == 0:
		print(0)
	elif sum1 % 2 == 1 and sum2 % 2 == 1 and exist and (n > 1):
		print(1)
	elif sum1 % 2 == 0 and sum2 % 1 == 1 and exist and (n > 1):
		print(1)
	else:
		print(-1)
main()


n = int(input())
t = 0
u = 0
a = []
b = []
cnt = 0
for i in range(n):
	(x, y) = map(int, input().split())
	t += x
	u += y
	a.append(x)
	b.append(y)
if u % 2 == 0 and t % 2 == 0:
	print(0)
else:
	for i in range(n):
		if a[i] % 2 == 0 and b[i] % 2 != 0 or (a[i] % 2 != 0 and b[i] % 2 == 0):
			t -= a[i]
			t += b[i]
			u -= b[i]
			u += a[i]
			cnt += 1
		if t % 2 == 0 and u % 2 == 0:
			print(cnt)
			break
		else:
			continue
	else:
		print(-1)


n = int(input())
(x, y, sumDom) = ([], [], [])
for i in range(n):
	(xi, yi) = map(int, input().split())
	x.append(xi)
	y.append(yi)
	sumDom.append((xi + yi) % 2)
sumX = sum(x)
sumY = sum(y)
if sumX % 2 == 0 and sumY % 2 == 0:
	ans = 0
elif (sumX + sumY) % 2 == 1:
	ans = -1
else:
	res = sumDom.count(1)
	if res > 0:
		ans = 1
	else:
		ans = -1
print(ans)


check = False
n = int(input())
(left, right) = (0, 0)
for _ in range(n):
	(l, r) = map(int, input().split())
	check = check or l % 2 != r % 2
	left += l % 2
	right += r % 2
if right % 2 == 0 and left % 2 == 0:
	print(0)
elif right % 2 and left % 2:
	print((-1, 1)[check and n > 1])
else:
	print(-1)


n = int(input())
a = []
b = []
for i in range(n):
	(x, y) = list(map(int, input().strip().split()))
	a.append(x)
	b.append(y)
top_sum = sum(a)
bottom_sum = sum(b)
if top_sum % 2 == 0 and bottom_sum % 2 == 0:
	print(0)
elif top_sum % 2 and bottom_sum % 2:
	flag = False
	for i in range(n):
		if a[i] % 2 ^ b[i] % 2:
			print(1)
			flag = True
			break
	if not flag:
		print(-1)
else:
	print(-1)


n = int(input())
(LR, L, R) = (0, 0, 0)
for i in range(n):
	(x, y) = list(map(int, input().split()))
	if x % 2 == y % 2 == 0:
		continue
	elif x % 2 == y % 2 == 1:
		LR += 1
	elif y % 2 == 1:
		R += 1
	elif x % 2 == 1:
		L += 1
LR = LR % 2
if (L + R) % 2 == 1:
	print(-1)
else:
	if L % 2 == R % 2 == 0:
		if LR == 0:
			print(0)
		if LR == 1:
			if L == R == 0:
				print(-1)
			else:
				print(1)
	if L % 2 == R % 2 == 1:
		if LR == 0:
			print(1)
		if LR == 1:
			print(0)


n = int(input())
(first, second) = ([], [])
for i in range(n):
	(a, b) = map(int, input().split())
	first.append(a)
	second.append(b)
flag = -1
if sum(first) % 2 == 0 and sum(second) % 2 == 0:
	flag = 0
	print('0')
else:
	for i in range(n):
		temp = first[i]
		first[i] = second[i]
		second[i] = temp
		if sum(first) % 2 == 0 and sum(second) % 2 == 0:
			flag = 1
			print(flag)
			break
	if flag != 1 and flag != 0:
		print(flag)


import sys
input = sys.stdin.readline
from math import log2, log, ceil

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

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

def primefs(n):
	primes = {}
	while n % 2 == 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:
			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):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	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(1000000.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 str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
odd_odd = odd_even = even_odd = 0
for _ in range(n):
	(x, y) = int_array()
	if x % 2 != 0:
		if y % 2 != 0:
			odd_odd += 1
		else:
			odd_even += 1
	elif y % 2 != 0:
		even_odd += 1
if odd_odd % 2 == 0:
	if odd_even % 2 != 0 and even_odd % 2 != 0:
		print(1)
	elif odd_even % 2 == 0 and even_odd % 2 == 0:
		print(0)
	else:
		print(-1)
elif odd_even % 2 != 0 and even_odd % 2 != 0:
	print(0)
elif odd_even % 2 == 0 and even_odd % 2 == 0:
	if odd_even + even_odd > 0:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
d = [[int(x) for x in input().split()] for _ in range(n)]
s1 = sum((x[0] for x in d))
s2 = sum((x[1] for x in d))
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
	exit(0)
if s1 % 2 != s2 % 2:
	print(-1)
	exit(0)
for (a, b) in d:
	if a % 2 != b % 2:
		print(1)
		exit(0)
print(-1)


def getIn():
	return input().strip()
evod = {}
odev = {}
n = int(getIn())
(usum, dsum) = (0, 0)
for i in range(n):
	(u, d) = getIn().split(' ')
	(u, d) = (int(u), int(d))
	if u % 2 == 0 and d % 2 != 0:
		evod[u, d] = evod.get((u, d), 0) + 1
	if u % 2 != 0 and d % 2 == 0:
		odev[u, d] = odev.get((u, d), 0) + 1
	usum += u
	dsum += d
if usum % 2 == 0 and dsum % 2 == 0:
	print(0)
elif usum % 2 == 0 and dsum % 2 != 0:
	print(-1)
elif usum % 2 != 0 and dsum % 2 == 0:
	print(-1)
elif usum % 2 != 0 and dsum % 2 != 0:
	if len(evod.keys()) > 0 or len(odev.keys()) > 0:
		print(1)
	else:
		print(-1)


def main():
	n = int(input())
	lsta = []
	lstb = []
	odda = 0
	oddb = 0
	for i in range(n):
		(a, b) = list(map(int, input().split()))
		if a % 2 != 0:
			odda += 1
		if b % 2 != 0:
			oddb += 1
		lsta.append(a)
		lstb.append(b)
	if n % 2 != 0 and odda == n and (oddb == n):
		print(-1)
	elif odda == 0 and oddb == 0:
		print(0)
	elif odda % 2 == 0 and oddb % 2 == 0:
		print(0)
	elif odda % 2 != 0 and oddb % 2 == 0 or (odda % 2 == 0 and oddb % 2 != 0):
		print(-1)
	elif odda % 2 != 0 and oddb % 2 != 0:
		isprint = 0
		for i in range(n):
			if lsta[i] % 2 == 0 and lstb[i] % 2 != 0 or (lsta[i] % 2 != 0 and lstb[i] % 2 == 0):
				print(1)
				isprint = 1
				break
		if isprint == 0:
			print(-1)
t = 1
while t != 0:
	main()
	t -= 1


import sys
import time
import os
from math import sqrt, log, log2, ceil, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial
from copy import copy, deepcopy
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
mint = lambda : map(int, inp().split())
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()

def permute(nums):

	def fun(arr, nums, cur, v):
		if len(cur) == len(nums):
			arr.append(cur.copy())
		i = 0
		while i < len(nums):
			if v[i]:
				i += 1
				continue
			else:
				cur.append(nums[i])
				v[i] = 1
				fun(arr, nums, cur, v)
				cur.pop()
				v[i] = 0
				i += 1
		return arr
	res = []
	nums.sort()
	v = [0] * len(nums)
	return fun(res, nums, [], v)

def subsets(res, index, arr, cur):
	res.append(cur.copy())
	for i in range(index, len(arr)):
		cur.append(arr[i])
		subsets(res, i + 1, arr, cur)
		cur.pop()
	return res

def sieve(N):
	root = int(sqrt(N))
	primes = [1] * (N + 1)
	(primes[0], primes[1]) = (0, 0)
	for i in range(2, root + 1):
		if primes[i]:
			for j in range(i * i, N + 1, i):
				primes[j] = 0
	return primes

def bs(arr, l, r, x):
	if x < arr[0] or x > arr[len(arr) - 1]:
		return -1
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def solve():
	n = iinp()
	a = []
	b = []
	for i in range(n):
		(aa, bb) = mint()
		a.append(aa)
		b.append(bb)
	if not sum(a) & 1 and (not sum(b) & 1):
		print(0)
		return
	if sum(a) & 1 and (not sum(b) & 1) or (not sum(a) & 1 and sum(b) & 1):
		print(-1)
	else:
		for i in range(n):
			if a[i] & 1 and (not b[i] & 1) or (not a[i] & 1 and b[i] & 1):
				print(1)
				return
		print(-1)
start_time = time.time()
s = sieve(10 ** 6)
solve()


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()
	(x, y, c) = (0, 0, 0)
	for i in range(n):
		(a, b) = mp()
		x += a
		y += b
		if a % 2 != b % 2:
			c += 1
	if x % 2 == 0 and y % 2 == 0:
		pr(0)
		return
	if x % 2 != y % 2:
		pr(-1)
		return
	pr(1 if c else -1)
for _ in range(1):
	solve()


n = int(input())
(OE, EO) = (0, 0)
(leftSum, rightSum) = (0, 0)
for _ in range(n):
	(a, b) = [int(x) % 2 for x in input().split(' ')]
	leftSum += a
	rightSum += b
	if a ^ b:
		if a:
			OE += 1
		else:
			EO += 1
leftSum %= 2
rightSum %= 2
if not leftSum ^ rightSum:
	if leftSum & 1:
		if OE or EO:
			print(1)
		else:
			print(-1)
	else:
		print(0)
else:
	print(-1)


n = int(input())
pieces = []
sum_total = 0
sum_left = 0
for i in range(1, n + 1):
	keys = []
	piece = input().split()
	keys = [int(x) for x in piece]
	sum_total += sum(keys)
	pieces.append(keys)
canrotate = False
for i in range(n):
	sum_left += pieces[i][0]
	if pieces[i][0] % 2 != pieces[i][1] % 2:
		canrotate = True
if sum_total % 2 == 1:
	print(-1)
elif not canrotate and sum_left % 2 == 1:
	print(-1)
elif sum_left % 2 == 1:
	print(1)
else:
	print(0)


n = int(input())
t1 = t2 = c = 0
for i in range(n):
	(a1, a2) = map(int, input().split())
	t1 += a1
	t2 += a2
	if (a1 + a2) % 2 != 0:
		c += 1
if (t2 + t1) % 2 == 0:
	if t1 % 2 == 0:
		print(0)
	elif t1 % 2 != 0 and c > 0:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
(x, y) = ([0] * n, [0] * n)
for i in range(n):
	(x[i], y[i]) = map(int, input().split())
sumX = sum(x)
sumY = sum(y)
res = -1
if sumX % 2 == 0 and sumY % 2 == 0:
	res = 0
elif sumX % 2 == 1 and sumY % 2 == 1:
	for i in range(n):
		if x[i] % 2 != y[i] % 2:
			res = 1
print(res)


eo = 0
(top, bottom) = (0, 0)
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a % 2 == 0 and b % 2 == 1 or (a % 2 == 1 and b % 2 == 0):
		eo += 1
	(top, bottom) = (top + a, bottom + b)
if top % 2 == 0 and bottom % 2 == 0:
	print(0)
elif top % 2 == 1 and bottom % 2 == 1:
	if eo >= 1:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
dominos = [list(map(int, input().split())) for i in range(n)]
sum_1 = 0
sum_2 = 0
ind = False
for i in range(n):
	sum_1 += dominos[i][0] % 2
	sum_1 %= 2
	sum_2 += dominos[i][1] % 2
	sum_2 %= 2
	if dominos[i][1] % 2 != dominos[i][0] % 2:
		ind = True
if sum_1 == sum_2 == 1 and ind:
	print(1)
elif sum_1 == sum_2 == 0:
	print(0)
else:
	print(-1)


N = int(input())
su = 0
sl = 0
canF = False
for i in range(N):
	arr = input().split(' ')
	a = int(arr[0])
	b = int(arr[1])
	if a % 2 == 0 and b % 2 == 1 or (a % 2 == 1 and b % 2 == 0):
		canF = True
	su += a
	sl += b
ans = -1
if (su + sl) % 2 == 1:
	ans = -1
elif su % 2 == 0 and sl % 2 == 0:
	ans = 0
elif canF:
	ans = 1
else:
	ans = -1
print(ans)


n = int(input())
u = []
l = []
for i in range(n):
	k = list(map(int, input().split()))
	u.append(k[0] % 2)
	l.append(k[1] % 2)
x = sum([l[i] != u[i] for i in range(n)])
if sum(u) % 2 == 0 and sum(l) % 2 == 0:
	print('0')
elif x % 2 == 0 and x != 0:
	print('1')
else:
	print('-1')


t = int(input())
u = []
d = []
sw = 0
for i in range(t):
	u.append(0)
	d.append(0)
	(u[i], d[i]) = map(int, input().split())
	if u[i] % 2 == 0 and d[i] % 2 == 1 or (u[i] % 2 == 1 and d[i] % 2 == 0):
		sw = 1
su = sum(u)
sd = sum(d)
if su % 2 == 0 and sd % 2 == 0:
	print('0')
elif su % 2 == 1 and sd % 2 == 1:
	if sw:
		print('1')
	else:
		print('-1')
else:
	print('-1')


l = []
for i in range(int(input())):
	t = list(map(int, input().split()))
	l.append(t)
d = {'f': 0, 's': 0}
sm1 = 0
sm2 = 0
for i in range(len(l)):
	if l[i][0] % 2 != 0:
		d['f'] += 1
	if l[i][1] % 2 != 0:
		d['s'] += 1
	sm1 += l[i][0]
	sm2 += l[i][1]
if d['f'] % 2 == 0 and d['s'] % 2 == 0:
	print(0)
elif d['f'] % 2 != 0 and d['s'] % 2 != 0:
	f = 0
	for i in range(len(l)):
		if l[i][0] % 2 == 0 and l[i][1] % 2 != 0:
			print(1)
			f = 1
			break
		elif l[i][0] % 2 != 0 and l[i][1] % 2 == 0:
			print(1)
			f = 1
			break
	if f == 0:
		print(-1)
else:
	print(-1)


Flag = True
upper = 0
lower = 0
Row_of_bones = []
n = int(input())
for i in range(n):
	x = list(map(int, input().split()))
	Row_of_bones.append(x)

def check_parity() -> bool:
	(upp, low) = (0, 0)
	for i in Row_of_bones:
		upp += i[0]
		low += i[1]
	if upp % 2 == 0 and low % 2 == 0:
		return True
	else:
		return False
for i in Row_of_bones:
	upper += i[0]
	lower += i[1]
while Flag:
	if upper % 2 == 0 and lower % 2 == 0:
		print(0)
		break
	elif n == 1:
		print(-1)
		break
	else:
		count = 0
		for i in Row_of_bones:
			(i[0], i[1]) = (i[1], i[0])
			count += 1
			if check_parity():
				print(1)
				break
		if count == n:
			print(-1)
		break


def func():
	(left, right) = (0, 0)
	n = int(input())
	parity = False
	for _ in range(n):
		(l, r) = map(int, input().split())
		left += l
		right += r
		if l % 2 != r % 2:
			parity = True
	if left % 2 == 0:
		if right % 2 == 0:
			return 0
		else:
			return -1
	elif right % 2 == 0:
		return -1
	else:
		return 1 if parity else -1
print(func())


n = int(input())
mat = []
flag = False
for i in range(n):
	row = list(map(int, input().split()))
	mat.append(row)
for num in mat:
	if num[0] % 2 == 0 and num[1] % 2 != 0:
		flag = True
		break
	elif num[0] % 2 != 0 and num[1] % 2 == 0:
		flag = True
		break
mat = list(zip(*mat))
if sum(mat[0]) % 2 == 0 and sum(mat[1]) % 2 == 0:
	print(0)
elif sum(mat[0]) % 2 == 1 and sum(mat[1]) % 2 == 1 and (flag == True):
	print(1)
else:
	print(-1)


n = int(input())
A = [0 for q in range(n)]
B = [0 for q in range(n)]
for i in range(n):
	(A[i], B[i]) = map(int, input().split())
s1 = sum(A)
s2 = sum(B)
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 == 1 and s2 % 2 == 1:
	p = 0
	for i in range(n):
		if A[i] % 2 != B[i] % 2:
			p = 1
			break
	if p == 1:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
a = []
b = []
c = []
for i in range(n):
	s = input().split()
	a.append(int(s[0]))
	b.append(int(s[1]))
	c.append(abs(a[-1] - b[-1]) % 2)
sum_a = sum(a)
sum_b = sum(b)
if sum_a % 2 == 0 and sum_b % 2 == 0:
	print(0)
elif sum_a % 2 != 0 and sum_b % 2 != 0:
	if 1 in c:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
x = 0
y = 0
a = []
t = 0
for i in range(n):
	l = list(map(int, input().strip().split(' ')))
	x += l[0]
	y += l[1]
	if x % 10 % 2 != 0 or y % 10 % 2 != 0:
		a.append(l)
if x % 10 % 2 != 0 or y % 10 % 2 != 0:
	for i in a:
		x -= i[0]
		y -= i[1]
		x += i[1]
		y += i[0]
		if x % 2 == 0 and y % 2 == 0:
			print(1)
			t = 1
			break
		x -= i[1]
		y -= i[0]
		x += i[0]
		y += i[1]
else:
	print(0)
	t = 1
if t == 0:
	print(-1)


def check(list):
	c = 0
	for i in list:
		if i % 2 != 0:
			c += 1
	if c % 2 == 0:
		return True
	return False
n = int(input())
a = []
b = []
for i in range(n):
	(c, d) = map(int, input().split())
	a.append(c)
	b.append(d)
time = 0
if check(a) and check(b):
	print(time)
elif check(a) == True and check(b) == False or (check(a) == False and check(b) == True):
	print(-1)
else:
	for i in range(n):
		if a[i] % 2 != 0 and b[i] % 2 == 0 or (a[i] % 2 == 0 and b[i] % 2 != 0):
			time += 1
			break
	if time == 0:
		print(-1)
	else:
		print(1)


n = int(input())
low_list = []
up_list = []
for _ in range(n):
	[a, b] = list(map(int, input().split()))
	up_list.append(a)
	low_list.append(b)
sum_up = 0
sum_low = 0
for i in range(len(up_list)):
	sum_up += up_list[i]
for j in range(len(low_list)):
	sum_low += low_list[j]
if sum_up % 2 == 0 and sum_low % 2 == 0:
	print(0)
elif sum_up % 2 == 0 and sum_low % 2 == 1:
	print(-1)
elif sum_up % 2 == 1 and sum_low % 2 == 0:
	print(-1)
else:
	time = 0
	for i in range(len(up_list)):
		if up_list[i] % 2 == 1 and low_list[i] % 2 == 0 or (low_list[i] % 2 == 1 and up_list[i] % 2 == 0):
			temp = up_list[i]
			up_list[i] = low_list[i]
			low_list[i] = temp
			time += 1
			break
		else:
			continue
	if sum(up_list) % 2 == 0 and sum(low_list) % 2 == 0:
		print(time)
	else:
		print(-1)


n = int(input())
A = []
B = []
for i in range(n):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
possible = 0
for i in range(n):
	if A[i] % 2 == 0 and B[i] % 2 != 0 or (B[i] % 2 == 0 and A[i] % 2 != 0):
		possible = 1
		break
p = sum(A)
q = sum(B)
if p % 2 == 0 and q % 2 == 0:
	print(0)
elif p % 2 != 0 and q % 2 != 0:
	if possible:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
u = []
d = []
for i in range(n):
	(x, y) = map(int, input().split())
	u.append(x)
	d.append(y)
su = sum(u)
sd = sum(d)
if su % 2 == 0 and sd % 2 == 0:
	print(0)
else:
	test = 0
	for i in range(n):
		if u[i] % 2 != 0 and d[i] % 2 == 0 or (u[i] % 2 == 0 and d[i] % 2 != 0):
			test = 1
			su = su - u[i] + d[i]
			sd = sd - d[i] + u[i]
			if su % 2 == 0 and sd % 2 == 0:
				print(1)
				break
			else:
				print(-1)
				break
	if test == 0:
		print(-1)


def xor(t1, t2):
	(a1, b1) = t1
	(a2, b2) = t2
	return (a1 ^ a2, b1 ^ b2)
n = int(input())
(x, y) = ([], [])
for _ in range(n):
	(xi, yi) = list(map(int, input().split()))
	x.append(xi % 2)
	y.append(yi % 2)
(effective, non_effective) = ([], [])
for t in zip(x, y):
	if t == (0, 0) or t == (1, 1):
		non_effective.append(t)
	else:
		effective.append(t)
target = (0, 0)
for t in non_effective:
	target = xor(target, t)
present = (0, 0)
for t in effective:
	present = xor(present, t)
if target == present:
	print(0)
elif target == xor(present, (1, 1)) and len(effective) != 0:
	print(1)
else:
	print(-1)


n = int(input())
list = []
for i in range(n):
	(x, y) = [int(i) for i in input().split()]
	list.append([x, y])
sumupper = 0
sumlower = 0
for i in range(n):
	sumupper += list[i][0]
	sumlower += list[i][1]
if sumupper % 2 == 0 and sumlower % 2 == 0:
	print(0)
elif sumupper % 2 != 0 and sumlower % 2 == 0:
	print(-1)
elif sumupper % 2 == 0 and sumlower % 2 != 0:
	print(-1)
else:
	eo = 0
	oo = 0
	for i in range(n):
		if list[i][0] % 2 != 0 and list[i][1] % 2 != 0:
			oo += 1
		elif list[i][0] % 2 == 0 and list[i][1] % 2 != 0:
			eo += 1
		elif list[i][0] % 2 != 0 and list[i][1] % 2 == 0:
			eo += 1
	if eo == 0:
		print(-1)
	else:
		print(1)


from sys import exit
N = int(input())
A = [tuple((int(j) for j in input().split())) for i in range(N)]
(S1, S2) = (0, 0)
for (a, b) in A:
	S1 += a
	S2 += b
if S1 % 2 == 0 and S2 % 2 == 0:
	print(0)
	exit()
if (S1 % 2 == 0) ^ (S2 % 2 == 0):
	print(-1)
	exit()
for (a, b) in A:
	if (a % 2 == 0) ^ (b % 2 == 0):
		print(1)
		exit()
print(-1)


n = int(input())
a = [[*map(int, input().split())] for i in range(n)]
up = sum([i[0] for i in a])
down = sum([i[1] for i in a])
if (up + down) % 2:
	print(-1)
	quit()
if up % 2 and down % 2:
	print(1 if len([*filter(lambda x: (x[0] + x[1]) % 2, a)]) > 0 else -1)
else:
	print(0)


n = int(input())
s1 = 0
s2 = 0
b1 = False
for i in range(n):
	(a, b) = map(int, input().split())
	if a % 2 != 0 and b % 2 == 0:
		b1 = True
	elif a % 2 == 0 and b % 2 != 0:
		b1 = True
	s1 += a
	s2 += b
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 & 1 and s2 & 1 and b1:
	print(1)
else:
	print(-1)


import math
n = int(input())
up = 0
down = 0
f = 0
for i in range(n):
	(x, y) = map(int, input().split())
	up += x % 2
	down += y % 2
	if x % 2 != y % 2:
		f = 1
if up % 2 == down % 2:
	if up % 2 == 0:
		print(0)
	elif f:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
leftside = 0
rightside = 0
c = 0
for i in range(0, n):
	(x, y) = map(int, input().split())
	leftside += x
	rightside += y
	if x % 2 == 0 and y % 2 == 1:
		c += 1
	elif x % 2 == 1 and y % 2 == 0:
		c += 1
if leftside % 2 == 0 and rightside % 2 == 0:
	print(0)
elif (leftside + rightside) % 2 == 0 and c >= 1:
	print(1)
else:
	print(-1)


n = int(input())
nech1 = 0
nech2 = 0
ch_n = 0
n_ch = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a % 2 == 1 and b % 2 == 0:
		n_ch = 1
	elif a % 2 == 0 and b % 2 == 1:
		ch_n = 1
	if a % 2 == 1:
		nech1 = (nech1 + 1) % 2
	if b % 2 == 1:
		nech2 = (nech2 + 1) % 2
if nech1 + nech2 == 0:
	print(0)
elif (nech1 + nech2) % 2 == 1:
	print(-1)
elif ch_n == 0 and n_ch == 0:
	print(-1)
else:
	print(1)


n = int(input())
first_half = []
second_half = []
ODD_FH = EVEN_FH = ODD_SH = EVEN_SH = ODD_EVEN = 0
for _ in range(n):
	xy = input().split(' ')
	fh = int(xy[0])
	sh = int(xy[1])
	first_half.append(fh)
	second_half.append(sh)
	if fh % 2 == 0:
		EVEN_FH += 1
	elif fh % 2 != 0:
		ODD_FH += 1
	if sh % 2 == 0:
		EVEN_SH += 1
	elif sh % 2 != 0:
		ODD_SH += 1
	if sh % 2 == 0 and fh % 2 != 0:
		ODD_EVEN += 1
	elif fh % 2 == 0 and sh % 2 != 0:
		ODD_EVEN += 1
if ODD_SH % 2 == 0 and ODD_FH % 2 == 0:
	print(0)
elif ODD_SH % 2 == 0 and ODD_FH % 2 != 0:
	print(-1)
elif ODD_SH % 2 != 0 and ODD_FH % 2 == 0:
	print(-1)
elif ODD_EVEN > 1:
	print(1)
else:
	print(-1)


n = int(input())
upper = []
lower = []
for i in range(n):
	(u, l) = map(int, input().split())
	upper.append(u)
	lower.append(l)
if sum(lower) % 2 == 0 and sum(upper) % 2 == 0:
	print(0)
else:
	c = 0
	for i in range(n):
		if lower[i] % 2 == 0 and upper[i] % 2 != 0 or (lower[i] % 2 != 0 and upper[i] % 2 == 0):
			(lower[i], upper[i]) = (upper[i], lower[i])
			c += 1
		if sum(lower) % 2 == 0 and sum(upper) % 2 == 0:
			break
		elif i == n - 1:
			c = -1
	print(c)


uh = []
lh = []
oc = False
for i in range(int(input())):
	(u, l) = input().split()
	u = int(u)
	l = int(l)
	if u % 2 == 1 and l % 2 == 0 or (u % 2 == 0 and l % 2 == 1):
		oc = True
	uh.append(int(u))
	lh.append(int(l))
if (sum(uh) + sum(lh)) % 2 == 1:
	print(-1)
elif sum(uh) % 2 == 0 and sum(lh) % 2 == 0:
	print(0)
else:
	print(1 if oc else -1)


n = int(input())
u = []
l = []
for i in range(n):
	(x, y) = map(int, input().split())
	u.append(x)
	l.append(y)
us = sum(u)
ls = sum(l)
if us % 2 == 0 and ls % 2 == 0:
	print(0)
elif us % 2 != 0 and ls % 2 != 0:
	f = 0
	for i in range(n):
		if u[i] % 2 == 0 and l[i] % 2 != 0 or (u[i] % 2 != 0 and l[i] % 2 == 0):
			f = 1
			break
	if f == 1:
		print(1)
	else:
		print(-1)
else:
	print(-1)


import sys
n = int(input())
(a, b) = ([], [])
for i in range(n):
	(x, y) = list(map(int, input().split()))
	a.append(x)
	b.append(y)
if sum(a) % 2 == sum(b) % 2 == 0:
	print(0)
else:
	for i in range(n):
		(a[i], b[i]) = (b[i], a[i])
		if sum(a) % 2 == sum(b) % 2 == 0:
			print(1)
			return
		(a[i], b[i]) = (b[i], a[i])
	for i in range(n):
		for j in range(i + 1, n):
			(a[i], b[i]) = (b[i], a[i])
			(a[j], b[j]) = (b[j], a[j])
			if sum(a) % 2 == sum(b) % 2 == 0:
				prin(2)
				return
			(a[i], b[i]) = (b[i], a[i])
			(a[j], b[j]) = (b[j], a[j])
	print('-1')


n = int(input())
(x, y) = (0, 0)
(c, s) = (0, 0)
for i in range(n):
	(o, p) = map(int, input().split())
	if o % 2 == 0 and p % 2 == 1:
		y = y + 1
	elif o % 2 == 1 and p % 2 == 0:
		x = x + 1
	c = c + o
	s = s + p
if s % 2 == 1 and c % 2 == 1:
	if x >= 1 or y >= 1:
		print(1)
	else:
		print(-1)
elif s % 2 == 0 and c % 2 == 0:
	print(0)
else:
	print(-1)


n = int(input())
tablets = []
up = []
down = []
thereis = False
for i in range(n):
	(x, y) = [int(i) for i in input().split()]
	parity = (x + y) % 2
	if parity:
		thereis = True
	tablets.append((x, y, (x + y) % 2))
	up.append(x)
	down.append(y)
sum_up = sum(up) % 2
sum_down = sum(down) % 2
if sum_up and sum_down and thereis:
	print(1)
elif sum_up ^ sum_down:
	print(-1)
elif sum_up and sum_down and (not thereis):
	print(-1)
else:
	print(0)


n = int(input())
supper = 0
slower = 0
arr = []
alag = 0
for i in range(n):
	(x, y) = map(int, input().split())
	arr.append([x, y])
	if x % 2 == 0 and y % 2 == 1:
		alag += 1
	if x % 2 == 1 and y % 2 == 0:
		alag += 1
	supper += x
	slower += y
if supper % 2 == 0 and slower % 2 == 1:
	print('-1')
	exit()
if supper % 2 == 1 and slower % 2 == 0:
	print(-1)
	exit()
if supper % 2 == 0 and slower % 2 == 0:
	print(0)
	exit()
if alag == 0:
	print(-1)
	exit()
print(1)


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

def solve():
	n = int(input())
	a = [0] * n
	b = [0] * n
	for i in range(n):
		(a[i], b[i]) = input_ints()
	if (sum(a) + sum(b)) % 2:
		print(-1)
	elif sum(a) % 2 == 0:
		print(0)
	else:
		for i in range(n):
			if a[i] % 2 + b[i] % 2 == 1:
				print(1)
				return
		print(-1)
solve()


n = int(input())
u = []
d = []
oo = 0
eo = 0
oe = 0
res = -1
for i in range(n):
	(x, y) = map(int, input().split())
	if x % 2 == 1 and y % 2 == 1:
		oo += 1
	elif x % 2 == 0 and y % 2 == 1:
		eo += 1
	elif x % 2 == 1 and y % 2 == 0:
		oe += 1
oo %= 2
eo2 = eo % 2
oe2 = oe % 2
if oo == 0:
	if oe2 == eo2:
		if oe2 == 1:
			res = 1
		else:
			res = 0
elif oe2 == eo2:
	if oe2 == 1:
		res = 0
	elif max(oe, eo) > 0:
		res = 1
print(res)


n = int(input())
s_h = False
s_l = 0
s_r = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	if x % 2 != y % 2:
		s_h = True
	s_l += x
	s_r += y
if s_l % 2 == 1 and s_r % 2 == 1 and s_h:
	print(1)
elif s_l % 2 == 0 == s_r % 2:
	print(0)
else:
	print(-1)


n = int(input())
list1 = []
for i in range(n):
	list1.append(list(map(int, input().split())))
even1 = 0
even2 = 0
sum1 = 0
sum2 = 0
count = 0
odd1l = []
odd2l = []
even1l = []
even2l = []
for i in range(len(list1)):
	if list1[i][0] % 2 == 0:
		even1 += 1
		even1l.append(i)
	else:
		odd1l.append(i)
	if list1[i][1] % 2 == 0:
		even2 += 1
		even2l.append(i)
	else:
		odd2l.append(i)
	sum1 += list1[i][0]
	sum2 += list1[i][0]
odd1 = n - even1
odd2 = n - even2
temp = 0
if odd1 % 2 == 0 and odd2 % 2 == 0:
	print(0)
elif odd1 % 2 != 0 and odd2 % 2 != 0:
	for i in odd1l:
		for j in even2l:
			if i == j:
				print(1)
				temp = 1
				break
			else:
				temp = 0
		if temp == 1:
			break
	if temp == 0:
		for i in odd2l:
			for j in even1l:
				if i == j:
					print(1)
					temp = 1
					break
				else:
					temp = 0
			if temp == 1:
				break
	if temp == 0:
		print(-1)
elif odd1 % 2 != 0 and odd2 % 2 == 0:
	print(-1)
elif odd1 % 2 != 0 and odd2 % 2 == 0:
	print(-1)
else:
	print(-1)


n = int(input())
b = []
s = 0
t = 0
for _ in range(0, n):
	a = list(map(int, input().split(' ')))
	s += a[0]
	t += a[1]
	b.append(a)
if s % 2 == 0 and t % 2 == 0:
	print(0)
elif s % 2 != 0 and t % 2 != 0:
	f = 0
	for x in range(n):
		if b[x][0] % 2 == 0 and b[x][1] % 2 != 0 or (b[x][0] % 2 != 0 and b[x][1] % 2 == 0):
			print(1)
			f = 1
			break
	if f == 0:
		print(-1)
else:
	print(-1)


n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
c = sum(a)
d = sum(b)
if c % 2 == 0 and d % 2 == 0:
	print(0)
elif c % 2 == 1 and d % 2 == 1:
	p = 0
	for i in range(n):
		if a[i] % 2 != b[i] % 2:
			p = 1
			break
	if p == 1:
		print(1)
	else:
		print(-1)
else:
	print(-1)


n = int(input())
x = []
for i in range(n):
	x.append(list(map(int, input().split(' '))))
if n == 1:
	if x[0][1] % 2 != 0 or x[0][0] % 2 != 0:
		print(-1)
	else:
		print(0)
else:
	sumu = 0
	sumd = 0
	for i in x:
		sumu += i[0]
		sumd += i[1]
	if sumu % 2 == 0 and sumd % 2 == 0:
		print(0)
	else:
		for i in x:
			if (sumu - i[0] + i[1]) % 2 == 0 and (sumd - i[1] + i[0]) % 2 == 0:
				print(1)
				exit()
		print(-1)


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


n = int(input())
lst = []
for i in range(n):
	a = input().split()
	a = map(int, a)
	lst.append(a)
lst = list(map(list, zip(*lst)))
x = sum(lst[0])
y = sum(lst[1])
ans = -1
if x % 2 == 0 and y % 2 == 0:
	ans = 0
elif x % 2 != 0 and y % 2 != 0:
	for i in range(n):
		if lst[0][i] % 2 == 0 and lst[1][i] % 2 != 0:
			ans = 1
			break
		elif lst[0][i] % 2 != 0 and lst[1][i] % 2 == 0:
			ans = 1
			break
print(ans)


n = int(input())
a = []
for i in range(0, n):
	a.append([int(j) for j in input().split()])

def isEven(x, l):
	up = 0
	down = 0
	for i in range(0, l):
		up += x[i][0]
		down += x[i][1]
	if up % 2 == 0 and down % 2 == 0:
		return 'yes'
	else:
		return 'no'
flag = 0
if isEven(a, n) == 'yes':
	print('0')
else:
	for i in range(0, n):
		c = a.copy()
		temp = c[i][0]
		c[i][0] = c[i][1]
		c[i][1] = temp
		if isEven(c, n) == 'yes':
			flag = 1
			break
	if flag == 1:
		print('1')
	else:
		print('-1')


def domino(lst):
	(sum1, sum2, flag) = (0, 0, False)
	for elem in lst:
		sum1 += elem[0]
		sum2 += elem[1]
		if elem[0] % 2 != elem[1] % 2:
			flag = True
	if (sum1 + sum2) % 2 != 0:
		return -1
	elif sum1 % 2 == 0 and sum2 % 2 == 0:
		return 0
	elif flag == 1:
		return 1
	else:
		return -1
n = int(input())
a = list()
for i in range(n):
	(s, t) = [int(j) for j in input().split()]
	a.append([s, t])
print(domino(a))


flag = X = Y = 0
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(flag, X, Y) = (flag | (x ^ y) & 1, X ^ x & 1, Y ^ y & 1)
print(0 if X + Y == 0 else 1 if flag and X & Y else -1)


n = int(input())
x = y = one_odd = 0
for i in range(n):
	(upper, lower) = map(int, input().strip().split())
	if upper % 2 == 0 and lower % 2 == 0:
		continue
	x += upper
	y += lower
	if upper % 2 == 1 and lower % 2 == 1:
		continue
	else:
		one_odd += 1
if x % 2 == 0 and y % 2 == 0:
	print(0)
elif x % 2 == 1 and y % 2 == 1 and (one_odd >= 1):
	print(1)
else:
	print(-1)


n = int(input())
f = 1
s1 = 0
s2 = 0
para = []
parb = []
for i in range(n):
	(a, b) = map(int, input().split())
	s1 += a
	s2 += b
	para.append(a % 2)
	parb.append(b % 2)
if s1 % 2 + s2 % 2 == 1:
	f = 0
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
	exit()
if s1 % 2 + s2 % 2 == 2:
	if all((para[i] == parb[i] for i in range(n))):
		f = 0
	else:
		f = 1
if f:
	print(1)
else:
	print(-1)


n = int(input())
sum1 = 0
sum2 = 0
i = 1
flag = 0
while i <= n:
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	sum1 += a
	sum2 += b
	if a % 2 != b % 2:
		flag = 1
	i = i + 1
if sum1 % 2 != sum2 % 2:
	print(-1)
elif sum1 % 2 == 0 and sum2 % 2 == 0:
	print(0)
elif flag:
	print(1)
else:
	print(-1)


l = []
s1 = 0
s2 = 0
fl = 0
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s1 += a
	s2 += b
	if a % 2 + b % 2 == 1:
		fl = 1
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 == 1 and s2 % 2 == 1:
	if fl:
		print(1)
	else:
		print(-1)
else:
	print(-1)


def watermelon():
	n = int(input())
	if n > 3 and n % 2 == 0:
		print('YES')
	else:
		print('NO')

def way_to_long():
	for _ in range(int(input())):
		s = input()
		if len(s) > 10:
			print(s[0] + str(len(s) - 2) + s[-1])
		else:
			print(s)

def marks():
	(n, m) = map(int, input().split())
	arr = []
	for _ in range(n):
		arr.append(input())
	cnt = 0
	for i in range(n):
		for j in range(m):
			sub = arr[i][j]
			for k in range(n):
				if arr[k][j] > sub:
					break
			else:
				cnt += 1
				break
	print(cnt)

def c_strings():
	s = input()
	t = input()
	i = 0
	j = 0
	cnt = 1
	while i < len(s) and j < len(t):
		if s[i] == t[j]:
			cnt += 1
			i += 1
			j += 1
		else:
			j += 1
	print(cnt)

def domino():
	n = int(input())
	du = 0
	dl = 0
	cnt = 0
	for i in range(n):
		(x, y) = map(int, input().split())
		if x % 2 != 0 and y % 2 == 0 or (x % 2 == 0 and y % 2 != 0):
			cnt += 1
		du += x
		dl += y
	if du % 2 == 0 and dl % 2 == 0:
		print(0)
	elif du % 2 == 0 and dl % 2 != 0 or (du % 2 != 0 and dl % 2 == 0):
		print(-1)
	elif cnt > 1:
		print(1)
	else:
		print(-1)
domino()


n = int(input())
up = []
do = []
for i in range(n):
	(a, b) = map(int, input().split())
	up.append(a)
	do.append(b)
sum_up = sum(up)
sum_do = sum(do)
if sum_up % 2 == 0 and sum_do % 2 == 0:
	print(0)
elif sum_up % 2 != sum_do % 2:
	print(-1)
else:
	found = False
	for i in range(n):
		if do[i] % 2 != up[i] % 2:
			found = True
			break
	print(1 if found else -1)


test = int(input())
i = 0
flag = 0
s1 = 0
s2 = 0
while i < test:
	(a, b) = map(int, input().split())
	s1 += a
	s2 += b
	if (a + b) % 2 != 0 and flag == 0:
		flag = 1
	i += 1
if s1 % 2 == 0 and s2 % 2 == 0:
	print('0')
elif (s1 + s2) % 2 == 1:
	print('-1')
elif flag == 1:
	print('1')
else:
	print('-1')


n = int(input())
array = []
upper = 0
lower = 0
for i in range(n):
	array.append(list(map(int, input().split())))
	upper += array[i][0]
	lower += array[i][1]
if upper % 2 == 0 and lower % 2 == 0:
	print(0)
elif upper % 2 == 0 and lower % 2 != 0:
	print(-1)
elif upper % 2 != 0 and lower % 2 == 0:
	print(-1)
else:
	flag = 0
	for i in range(n):
		if array[i][1] % 2 != 0 and array[i][0] % 2 == 0:
			flag = 1
			break
		if array[i][1] % 2 == 0 and array[i][0] % 2 != 0:
			flag = 1
			break
	if flag == 1:
		print(1)
	else:
		print(-1)


n = int(input())
flag = True
l = u = count = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if flag and (x % 2 == 0 and y % 2 != 0 or (x % 2 != 0 and y % 2 == 0)):
		count = 1
		flag = False
	u += x
	l += y
if u % 2 == l % 2 == 0:
	print(0)
elif (u % 2 == l % 2) != 0 and count == 1:
	print(1)
else:
	print(-1)


def solve(upper, lower):
	(su, sl) = (sum(upper), sum(lower))
	if (su + sl) % 2 != 0:
		return -1
	if su % 2 == 0:
		return 0
	for i in range(len(upper)):
		if (upper[i] + lower[i]) % 2 != 0:
			return 1
	return -1
n = int(input())
t = [list(map(int, input().split())) for _ in range(n)]
(u, l) = ([x[0] for x in t], [x[1] for x in t])
res = solve(u, l)
print(res)


n = int(input())
xy = [tuple(map(int, input().split())) for i in range(n)]
(a, b, zhi) = (sum([x[0] % 2 for x in xy]), sum([y[1] % 2 for y in xy]), False)
for kappa in xy:
	if kappa[0] % 2 != kappa[1] % 2:
		zhi = True
if (a + b) % 2 == 1 or (a + b > 0 and a % 2 == 1 and (zhi == False)):
	print(-1)
else:
	print(a % 2)


n = int(input())
x = []
y = []
for i in range(n):
	(a, b) = list(map(int, input().strip().split()))
	x.append(a)
	y.append(b)
c = 0
if sum(x) % 2 == 0 and sum(y) % 2 == 0:
	print(0)
elif sum(x) % 2 == 0 and sum(y) % 2 != 0:
	print(-1)
elif sum(x) % 2 != 0 and sum(y) % 2 == 0:
	print(-1)
else:
	for j in range(n):
		if x[j] % 2 == 0 and y[j] % 2 != 0 or (x[j] % 2 != 0 and y[j] % 2 == 0):
			c = 1
			break
	if c == 1:
		print(1)
	else:
		print(-1)


n = int(input())
A = [tuple(map(int, input().split())) for i in range(n)]
l = sum([a[0] for a in A])
r = sum([a[1] for a in A])
if l % 2 == 0 and r % 2 == 0:
	print(0)
elif l % 2 == 1 and r % 2 == 0 or (l % 2 == 0 and r % 2 == 1):
	print(-1)
else:
	for a in A:
		if a[0] % 2 != a[1] % 2:
			print(1)
			exit()
	print(-1)


n = int(input())
data = []
(c1, c2) = (0, 0)
flag = 0
for i in range(n):
	val = list(map(int, input().split()))
	data.append(tuple(val))
	c1 += val[0]
	c2 += val[1]
	if c1 % 2 != c2 % 2:
		flag = 1
if c1 % 2 == 1 and c2 % 2 == 1 and ((c1 + c2) % 2 == 0) and (n > 1) and (flag == 1):
	print(1)
elif c1 % 2 == 0 and c2 % 2 == 0:
	print(0)
else:
	print(-1)


n = int(input())
dic = {}
sumup = 0
sumlow = 0
change = False
for x in range(n):
	(up, low) = list(map(int, input().split(' ')))
	dic[up] = low
	sumup += up
	sumlow += low
	if sumup % 2 != sumlow % 2:
		change = True
if n == 1:
	if sumup % 2 == 0 and sumlow % 2 == 0:
		print(0)
	else:
		print(-1)
elif sumup % 2 == 1 and sumlow % 2 == 1:
	if change == True:
		print(1)
	else:
		print(-1)
elif sumup % 2 == 0 and sumlow % 2 == 0:
	print(0)
else:
	print(-1)


u = 0
l = 0
switch = False
for i in range(int(input())):
	temp = list(map(int, input().split(' ')))
	u += temp[0]
	l += temp[1]
	if temp[0] % 2 != temp[1] % 2:
		switch = True
if l % 2 == 0 and u % 2 == 0:
	print('0')
elif l % 2 == 1 and u % 2 == 1 and switch:
	print('1')
else:
	print('-1')


N = int(input())
dominos = [None] * N
for i in range(N):
	dominos[i] = list(map(int, input().split()))
sum_upper_lower = list(map(sum, zip(*dominos)))
if all((e % 2 == 0 for e in sum_upper_lower)):
	print('0')
	exit()
elif N == 1:
	if any((e % 2 != 0 for e in sum_upper_lower)):
		print('-1')
		exit()
else:
	num_of_seconds = 1
	for i in range(N):
		(dominos[i][0], dominos[i][1]) = (dominos[i][1], dominos[i][0])
		sum_upper_lower = list(map(sum, zip(*dominos)))
		if all((e % 2 == 0 for e in sum_upper_lower)):
			break
	sum_upper_lower = list(map(sum, zip(*dominos)))
	if any((e % 2 != 0 for e in sum_upper_lower)):
		print('-1')
		exit()
	else:
		print(num_of_seconds)


n = int(input())
upodds = 0
downodds = 0
flag = False
for _ in range(n):
	(x, y) = [int(x) for x in input().split()]
	c = 0
	if x % 2 != 0:
		upodds += 1
		c += 1
	if y % 2 != 0:
		downodds += 1
		c += 1
	if c == 1:
		flag = True
if upodds % 2 == 0 and downodds % 2 == 0:
	print(0)
elif upodds % 2 != 0 and downodds % 2 != 0 and (n > 1) and flag:
	print(1)
else:
	print(-1)


n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
x = [d[i][0] for i in range(n)]
y = [d[i][1] for i in range(n)]
time = 0
for i in range(n):
	if (sum(x) % 2 == 0) & (sum(y) % 2 == 0):
		break
	elif sum(d[i]) % 2:
		(d[i][0], d[i][1]) = (d[i][1], d[i][0])
		x[i] = d[i][0]
		y[i] = d[i][1]
		time = time + 1
if (sum(x) % 2 == 0) & (sum(y) % 2 == 0):
	pass
else:
	time = -1
print(time)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
upper = []
lower = []
for _ in range(n):
	(x, y) = map(int, input().split())
	upper.append(x)
	lower.append(y)
if sum(upper) % 2 == 0 and sum(lower) % 2 == 0:
	print(0)
elif sum(upper) % 2 == 1 and sum(lower) % 2 == 1:
	for i in range(n):
		if upper[i] % 2 + lower[i] % 2 == 1:
			print(1)
			break
	else:
		print(-1)
else:
	print(-1)


n = int(input())
(l1, l2, s1, s2) = ([], [], 0, 0)
for i in range(n):
	(a, b) = map(int, input().split())
	l1.append(a)
	l2.append(b)
	s1 += a
	s2 += b
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 != 0 and s2 % 2 != 0:
	ans = 0
	for i in range(n):
		if l1[i] % 2 != l2[i] % 2:
			s1 -= l1[i]
			s1 += l2[i]
			s2 -= l2[i]
			s2 += l1[i]
			ans += 1
			break
	if s1 % 2 == 0 and s2 % 2 == 0:
		print(ans)
	else:
		print(-1)
else:
	print(-1)


def main():
	n = int(input())
	l = [0, 0, 0, 0]
	for _ in range(n):
		(x, y) = map(int, input().split())
		l[(x & 1) * 2 + (y & 1)] += 1
	(_, x, y, z) = l
	x += y
	if x & 1:
		print(-1)
	elif x:
		print(y + z & 1)
	else:
		print(-(z & 1))
main()


n = int(input())
numImp = 0
imSup = 0
temtroca = False
for i in range(n):
	(x, y) = (int(k) for k in input().split())
	if x % 2 == 1:
		numImp += 1
		imSup += 1
	if y % 2 == 1:
		numImp += 1
	if (x + y) % 2 == 1:
		temtroca = True
if numImp % 2 == 0:
	if imSup % 2 == 0:
		print('0')
	elif temtroca:
		print('1')
	else:
		print('-1')
else:
	print('-1')


n = int(input())
x = []
y = []
for i in range(n):
	(xi, yi) = map(int, input().split(' '))
	x.append(xi)
	y.append(yi)
xs = sum(x)
ys = sum(y)
if xs % 2 == 0 and ys % 2 == 0:
	print(0)
elif xs % 2 == 1 and ys % 2 == 1:
	dif = False
	for i in range(n):
		if x[i] % 2 == 0 and y[i] % 2 != 0:
			dif = True
		elif x[i] % 2 != 0 and y[i] % 2 == 0:
			dif = True
		if dif:
			break
	if dif:
		print(1)
	else:
		print(-1)
else:
	print(-1)


N = int(input())
L = []
R = []
flg = False
for i in range(N):
	(l, r) = map(int, input().split())
	L.append(l)
	R.append(r)
	if l % 2 == 0 and r % 2 != 0 or (l % 2 != 0 and r % 2 == 0):
		flg = True
suml = sum(L)
sumr = sum(R)
if suml % 2 == 0 and sumr % 2 == 0:
	print(0)
else:
	if (suml + sumr) % 2 != 0:
		print(-1)
		exit()
	if N == 1:
		print(-1)
		exit()
	if flg:
		print(1)
	else:
		print(-1)


n = int(input())
matrix = []
for _ in range(n):
	matrix.append(list(map(int, input().split())))
uh_sum = 0
lh_sum = 0
diff_parity = False
for (i, j) in matrix:
	if (i + j) % 2 == 1:
		diff_parity = True
	uh_sum += i
	lh_sum += j
if uh_sum % 2 == 0 and lh_sum % 2 == 0:
	print(0)
elif uh_sum % 2 == 1 and lh_sum % 2 == 1 and diff_parity:
	print(1)
else:
	print(-1)


t = int(input())
l = []
s = []
for i in range(t):
	(x, y) = map(int, input().split())
	l.append(x)
	s.append(y)
ol = 0
os = 0
for i in l:
	if i % 2 != 0:
		ol += 1
for i in s:
	if i % 2 != 0:
		os += 1
if (os + ol) % 2 != 0:
	print(-1)
elif sum(l) % 2 == 0 and sum(s) % 2 == 0:
	print(0)
elif sum(l) % 2 != 0 and sum(s) % 2 != 0:
	flag = 0
	for i in range(len(s)):
		if s[i] % 2 != 0 or l[i] % 2 != 0:
			(s[i], l[i]) = (l[i], s[i])
		if sum(l) % 2 == 0 and sum(s) % 2 == 0:
			print(1)
			flag = 1
			break
	if flag == 0:
		print(-1)


from collections import *
n = int(input())
(a, b) = ([], [])
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
if (sum(a) + sum(b)) % 2 == 1:
	print(-1)
	exit(0)
if sum(a) % 2 == 0 and sum(b) % 2 == 0:
	print(0)
	exit(0)
for i in range(n):
	if (a[i] + b[i]) % 2 == 1:
		print(1)
		break
else:
	print(-1)


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()))
n = iinput()
a = []
(sum, sum1) = (0, 0)
for i in range(n):
	a.append(list(map(int, input().split())))
(col, col1, col2) = (0, 0, 0)
for i in range(n):
	if a[i][0] % 2 == 0:
		col += 1
	sum += a[i][0]
	if a[i][1] % 2 == 0:
		col1 += 1
	sum1 += a[i][1]
	col2 += (a[i][0] + a[i][1]) % 2
if col == n and col1 == n or (sum % 2 == 0 and sum1 % 2 == 0):
	print(0)
elif col2 == 0:
	print(-1)
elif col2 % 2 == 0:
	print(1)
else:
	print(-1)


n = int(input())
t_odd_even = 0
b_odd_even = 0
t_sum = 0
b_sum = 0
for _ in range(n):
	(x, y) = list(map(int, input().split()))
	t_sum += x
	b_sum += y
	if x % 2 == 1 and y % 2 == 0:
		t_odd_even += 1
	elif x % 2 == 0 and y % 2 == 1:
		b_odd_even += 1
if t_sum % 2 == 0 and b_sum % 2 == 0:
	print(0)
elif t_sum % 2 == 1 and b_sum % 2 == 1:
	if t_odd_even > 0 or b_odd_even > 0:
		print(1)
	else:
		print(-1)
else:
	print(-1)


upper = 0
lower = 0
double = 0
opposite = 0
for i in range(int(input())):
	bol = 0
	dom = input().split()
	if int(dom[0]) % 2 == 1:
		upper += 1
		bol += 1
	if int(dom[1]) % 2 == 1:
		lower += 1
		bol += 1
	if bol == 2:
		double += 1
	elif bol == 1:
		opposite += 1
if upper % 2 == 0 and lower % 2 == 0:
	print(0)
elif upper % 2 == 1 and lower % 2 == 1 and (double % 2 == 0 or opposite > 1):
	print(1)
else:
	print(-1)


part_1 = []
part_2 = []
odd = 0
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 != k % 2:
		odd += 1
	part_1.append(n)
	part_2.append(k)
if sum(part_1) % 2 == 0 and sum(part_2) % 2 == 0:
	print(0)
elif sum(part_1) % 2 != 0 and sum(part_2) % 2 != 0:
	if odd > 1:
		print(1)
	else:
		print(-1)
elif odd % 2 == 0:
	print(1)
else:
	print(-1)


n = int(input())
m = 0
v = 0
d = ''
k = ''
c = 0
for i in range(n):
	s = list(map(int, input().split()))
	a = int(s[0])
	b = int(s[1])
	d = d + str(a)
	k = k + str(b)
	m = m + a
	v = v + b
h = 0
q = 0
for j in range(333333):
	try:
		if m % 2 == 0 and v % 2 == 0:
			print(c)
			break
		else:
			m = m - int(d[h]) + int(k[h])
			v = v - int(k[h]) + int(d[h])
			h += 1
			q += 1
			c = 1
	except:
		break
if q == n:
	print(-1)


l1 = []
l2 = []
odd1 = []
odd2 = []
s = int(input())
for i in range(s):
	(a, b) = list(map(int, input().split()))
	if a % 2 != 0:
		odd1.append(i)
	if b % 2 != 0:
		odd2.append(i)
	l1.append(a)
	l2.append(b)
if s == 1:
	if l1[0] % 2 == 0 and l2[0] % 2 == 0:
		print(0)
	else:
		print(-1)
elif len(odd1) % 2 == 0 and len(odd2) % 2 == 0:
	print(0)
elif len(odd1) > 0 and len(odd2) > 0 and (odd1 == odd2):
	print(-1)
elif len(odd1) % 2 == 0 and len(odd2) % 2 != 0 or (len(odd2) % 2 == 0 and len(odd1) % 2 != 0):
	print(-1)
else:
	print(1)


n = int(input())
a = [0] * 2
b = [0] * 2
ok = 0
for i in range(n):
	(x, y) = list(map(int, input().split()))
	x = x % 2
	y = y % 2
	a[x] = a[x] + 1
	b[y] = b[y] + 1
	if x + y == 1:
		ok = 1
x = a[1]
y = b[1]
if x % 2 == 0 and y % 2 == 0:
	print(0)
elif ok and x % 2 and y % 2:
	print(1)
else:
	print(-1)


n = int(input())
cnt = 0
sl = 0
sr = 0
for i in range(n):
	(x, y) = map(int, input().split())
	sl = sl + x
	sr += y
	if x % 2 != y % 2:
		cnt = cnt + 1
if (sl + sr) % 2 == 1:
	print(-1)
elif sl % 2 == 0:
	print(0)
elif cnt > 0:
	print(1)
else:
	print(-1)


import math
n = int(input())
u = 0
l = 0
d = 0
for i in range(n):
	(x, y) = map(int, input().split())
	u += x
	l += y
	xs = x % 2
	ys = y % 2
	if xs != ys:
		d = 1
if u % 2 != 0 and l % 2 != 0:
	if d == 1:
		print(1)
	else:
		print(-1)
elif u % 2 == 0 and l % 2 == 0:
	print(0)
else:
	print(-1)


n = int(input())
u = []
l = []
for _ in range(n):
	x = input().split()
	u.append(int(x[0]))
	l.append(int(x[1]))
if sum(u) % 2 == 0 and sum(l) % 2 == 0:
	print(0)
elif sum(u) % 2 == 1 and sum(l) % 2 == 1:
	out = False
	for i in range(n):
		if u[i] % 2 != l[i] % 2:
			out = True
			break
	if out:
		print(1)
	else:
		print(-1)
else:
	print(-1)


cant = int(input())
high = []
lower = []
mix = 0
par = 0
impar = 0
for i in range(cant):
	num = input()
	num = num.split(' ')
	if int(num[0]) % 2 == 0 and int(num[1]) % 2 == 0:
		par += 1
	elif int(num[0]) % 2 != 0 and int(num[1]) % 2 != 0:
		impar += 1
	else:
		mix += 1
	lower.append(num[0])
	high.append(num[1])
if par == impar and mix == 0 or (par == 0 and impar == 0 and (mix % 2 != 0)) or (par == impar and impar == mix) or (mix == 0 and impar % 2 != 0) or (cant == 1 and (mix == 1 or impar == 1)):
	print(-1)
elif impar == 0 and mix == 0 or (par == 0 and mix == 0 and (impar % 2 == 0)):
	print(0)
elif par == 0 and impar == 0:
	if eval('+'.join(lower)) % 2 == 0 and mix % 2 == 0:
		print(0)
	else:
		print(1)
elif mix % 2 == 0 and impar % 2 != 0 or (mix % 2 == 0 and impar % 2 == 0):
	if eval('+'.join(lower)) % 2 == 0 and mix % 2 == 0:
		print(0)
	else:
		print(1)
else:
	print(-1)


n = int(input())
oddup = 0
odddown = 0
posswap = 0
for i in range(n):
	(up, down) = map(int, input().split())
	if up % 2 != down % 2:
		posswap += 1
	if up % 2 != 0:
		oddup += 1
	if down % 2 != 0:
		odddown += 1
if oddup % 2 == 0 and odddown % 2 == 0:
	print('0')
elif oddup % 2 == 1 and odddown % 2 == 1 and (posswap >= 1) and (n > 1):
	print('1')
elif n == 1:
	if oddup == 0 and odddown == 0:
		print('0')
	else:
		print('-1')
else:
	print('-1')


(x, y, z) = (0, 0, 0)
for i in range(int(input())):
	(a, b) = map(int, input().split())
	x += a
	y += b
	z += 11 if (a + b) % 2 else 0
if not x % 2 and (not y % 2):
	print(0)
else:
	print(1 if x % 2 and y % 2 and z else -1)


f = 0
x_sum = 0
y_sum = 0
n = int(input())
for i in range(n):
	(x, y) = map(int, input().strip().split(' '))
	if f == 0 and (x % 2 != 0 and y % 2 == 0 or (x % 2 == 0 and y % 2 != 0)):
		f = 1
	x_sum += x
	y_sum += y
if x_sum % 2 == 0 and y_sum % 2 == 0:
	print(0)
elif x_sum % 2 != 0 and y_sum % 2 == 0 or (x_sum % 2 == 0 and y_sum % 2 != 0):
	print(-1)
elif x_sum % 2 != 0 and y_sum % 2 != 0:
	if f == 1:
		print(1)
	else:
		print(-1)


t = int(input())
up = []
down = []
for i in range(t):
	(a, b) = list(map(int, input().split()))
	up.append(a)
	down.append(b)
(evenup, evendown, oddup, odddown) = (0, 0, 0, 0)
for i in up:
	if i & 1 == 0:
		evenup += 1
	else:
		oddup += 1
for i in down:
	if i & 1 == 0:
		evendown += 1
	else:
		odddown += 1
common = 0
for i in range(t):
	if up[i] & 1 == 1 and down[i] & 1 == 1:
		common += 1
if oddup == 1 and odddown == 1 and (t == 1):
	print('-1')
elif oddup - common == 0 and odddown - common == 0 and (oddup & 1 == 1):
	print('-1')
elif oddup % 2 == 1 and odddown % 2 == 1:
	print('1')
elif oddup % 2 == 0 and odddown % 2 == 0:
	print('0')
else:
	print('-1')


n = eval(input())
F = False
i = 0
p = 1
f = []
s = []
(sumf, sums) = (0, 0)
while i < n:
	x = input().split(' ')
	a = int(x[0])
	b = int(x[1])
	if a % 2 == 1 and b % 2 == 0 or (a % 2 == 0 and b % 2 == 1):
		F = True
	f = f + [a]
	s = s + [b]
	i += 1
i = 0
while i < n:
	sumf = sumf + f[i]
	sums = sums + s[i]
	i += 1
if n == 1:
	if a == 1 and b % 2 == 1 or (a % 2 == 1 and b == 1):
		print(-1)
	elif sumf % 2 == 0 and sums % 2 == 1 or (sumf % 2 == 1 and sums % 2 == 0):
		print(-1)
	else:
		print(0)
if n != 1:
	if sumf % 2 == 1 and sums % 2 == 1:
		if F:
			print(1)
		else:
			print(-1)
	if sumf % 2 == 0 and sums % 2 == 1 or (sumf % 2 == 1 and sums % 2 == 0):
		print(-1)
	elif sumf % 2 == 0 and sums % 2 == 0:
		print(0)


n = int(input())
(up, down, dom) = (0, 0, [])
for _ in range(n):
	dom.append(list((x % 2 for x in map(int, input().split()))))
	up += dom[_][0]
	down += dom[_][1]
if up % 2 == 0 and down % 2 == 1 or (up % 2 == 1 and down % 2 == 0):
	print('-1')
elif up % 2 == 1 and down % 2 == 1:
	if [1, 0] in dom or [0, 1] in dom:
		print('1')
	else:
		print('-1')
else:
	print('0')


n = int(input())
(a, b) = (0, 0)
(su, du) = (0, 0)
for i in range(n):
	(u, v) = list(map(int, input().split()))
	if u % 2 != 0 and v % 2 == 0:
		a += 1
	if u % 2 == 0 and v % 2 != 0:
		b += 1
	su += u
	du += v
if su % 2 != 0 and du % 2 != 0:
	if a >= 1 or b >= 1:
		print(1)
	else:
		print(-1)
elif su % 2 == 0 and du % 2 == 0:
	print(0)
else:
	print(-1)


import sys

class MyReader:

	def __init__(self):
		filename = 'file.in'
		if self.isLocal():
			self.file = open(filename)
		self.str = ['']
		self.ind = 1

	def isLocal(self):
		return len(sys.argv) > 1 and sys.argv[1] == 'SCHULLZ'

	def nextString(self):
		if self.isLocal():
			return self.file.read()
		else:
			return input()

	def nextInt(self):
		return int(self.nextToken())

	def nextToken(self):
		if self.ind >= len(self.str):
			self.ind = 0
			self.str = self.nextString().split()
		self.ind += 1
		return self.str[self.ind - 1]

def Solve():
	n = -1
	try:
		n = rdr.nextInt()
	except Exception:
		return False
	a = []
	b = []
	for i in range(0, n):
		a.append(rdr.nextInt())
		b.append(rdr.nextInt())
	sa = sum(a)
	sb = sum(b)
	if sa % 2 == 0 and sb % 2 == 0:
		print(0)
		return True
	if sa % 2 == 1 and sb % 2 == 1:
		for i in range(0, n):
			if a[i] % 2 != b[i] % 2:
				print(1)
				return True
		print(-1)
		return True
	print(-1)
	return True
rdr = MyReader()
if not rdr.isLocal():
	Solve()
else:
	while Solve():
		fgh = 1


import sys
n = int(input())
(upper, lower) = ([], [])
for _ in range(n):
	(x, y) = map(int, input().split())
	upper += [x % 2]
	lower += [y % 2]
c = 0
if upper.count(1) == n and lower.count(1) == n and (n % 2 == 1):
	print(-1)
	sys.exit(0)
while sum(upper) % 2 == 1 and sum(lower) % 2 == 1:
	non = 0
	for i in range(n):
		if upper[i] == 1 and lower[i] == 0 or (upper[i] == 0 and lower[i] == 1):
			(upper[i], lower[i]) = (lower[i], upper[i])
		else:
			non += 1
		if sum(upper) % 2 == 0 and sum(lower) % 2 == 0:
			break
	if non == n:
		break
	c += 1
if c == 0 and (sum(upper) % 2 == 1 or sum(lower) % 2 == 1):
	c = -1
print(c)


n = int(input())
x = []
y = []
up_odd = 0
low_odd = 0
for i in range(n):
	a = list(map(int, input().rstrip().split()))
	x += [a[0]]
	y += [a[1]]
	if a[0] % 2 != 0:
		up_odd += 1
	if a[1] % 2 != 0:
		low_odd += 1
rem_up = up_odd % 2
rem_low = low_odd % 2
ans = -1
if rem_low == 0 and rem_up == 0:
	ans = 0
elif rem_low == 1 and rem_up == 1:
	for i in range(n):
		if x[i] % 2 == 0 and y[i] % 2 == 1 or (x[i] % 2 == 1 and y[i] % 2 == 0):
			ans = 1
			break
print(ans)


n = int(input())
(sum_a, sum_b) = (0, 0)
even_odd = 0
for _ in range(n):
	(a, b) = map(lambda x: int(x) % 2, input().split())
	if a != b:
		even_odd += 1
	sum_a += a
	sum_b += b
if sum_a % 2 == 0 and sum_b % 2 == 0:
	print(0)
elif sum_a % 2 + sum_b % 2 == 2 and even_odd > 1:
	print(1)
else:
	print(-1)


A = []
B = []
for i in range(0, int(input())):
	(a, b) = list(map(int, input().split()))
	A.append(a)
	B.append(b)
	sumA = sum(A)
	sumB = sum(B)
if sumA % 2 == 0 and sumB % 2 == 0:
	print(0)
elif sumA % 2 == 1 and sumB % 2 == 1 and (len(A) != 1):
	k = 0
	for j in range(0, len(A)):
		if A[j] % 2 == 1 and B[j] % 2 == 0:
			k = 1
			print(1)
			break
		elif A[j] % 2 == 0 and B[j] % 2 == 1:
			k = 1
			print(1)
			break
	if k == 0:
		print(-1)
else:
	print(-1)


s1 = 0
s2 = 0
o1 = 0
o2 = 0
for _ in range(int(input())):
	(n1, n2) = map(int, input().split())
	s1 += n1
	s2 += n2
	if n1 % 2 != 0 and n2 % 2 == 0:
		o1 += 1
	if n1 % 2 == 0 and n2 % 2 != 0:
		o2 += 1
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 != 0 and s2 % 2 == 0:
	print(-1)
elif s1 % 2 == 0 and s2 % 2 != 0:
	print(-1)
elif s1 % 2 != 0 and s2 % 2 != 0:
	if o1 > 0 or o2 > 0:
		print(1)
	else:
		print(-1)


l = []
t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	l.append((m, n))
x = []
y = []
for (i, j) in l:
	x.append(i)
	y.append(j)
z1 = sum(x)
z2 = sum(y)
q = False
if z1 % 2 == 0 and z2 % 2 == 0:
	print(0)
	quit()
elif z1 % 2 != 0 and z2 % 2 != 0:
	for (i, j) in l:
		if i != j and i % 2 != j % 2:
			q = True
else:
	print(-1)
	quit()
if q:
	print(1)
else:
	print(-1)


n = int(input())
eo = 0
top = 0
bot = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	if a % 2 == 0 and b % 2 == 1 or (a % 2 == 1 and b % 2 == 0):
		eo += 1
	top += a
	bot += b
if top % 2 == 0 and bot % 2 == 0:
	print(0)
elif top % 2 == 0 and bot % 2 == 1 or (top % 2 == 1 and bot % 2 == 0):
	print(-1)
elif eo == 0:
	print(-1)
else:
	print(1)


n = int(input())
k1 = 0
k2 = 0
M = [list(map(int, input().split())) for i in range(n)]
t = 0
for i in range(n):
	k1 = k1 + M[i][0]
	k2 = k2 + M[i][1]
	if (M[i][0] - M[i][1]) % 2 != 0:
		t = 1
c = 0
if k1 % 2 == 0 and k2 % 2 != 0 or (k1 % 2 != 0 and k2 % 2 == 0):
	c = 1
	print(-1)
if k1 % 2 == 0 and k2 % 2 == 0 and (c == 0):
	c = 1
	print(0)
if c == 0:
	if k1 % 2 != 0 and k2 % 2 != 0:
		if t == 1:
			print(1)
		else:
			print(-1)


import sys
import math
from sys import stdin, stdout

def sieve(N):
	primeNumbers = [True] * (N + 1)
	primeNumbers[0] = False
	primeNumbers[1] = False
	i = 2
	while i * i <= N:
		j = i
		if primeNumbers[j]:
			while j * i <= N:
				primeNumbers[j * i] = False
				j += 1
		i += 1
	return primeNumbers

def getPrime(N):
	primes = sieve(N)
	result = []
	for i in range(len(primes)):
		if primes[i]:
			result.append(i)
	return result

def factor(N):
	factors = []
	i = 1
	while i * i <= N:
		if N % i == 0:
			factors.append(i)
			if i != N // i:
				factors.append(N // i)
		i += 1
	return sorted(factors)

def reduceB(b):
	mod = 0
	for i in range(0, len(b)):
		mod = (mod * 10 + ord(b[i])) % 1000000007
	return mod

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

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

def get_int():
	return int(input())

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

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

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

def main():
	n = int(input())
	a = 0
	b = 0
	c = 0
	for i in range(0, n):
		(xi, yi) = get_ints_in_variables()
		a += xi
		b += yi
		if not c and (xi + yi) % 2:
			c = 1
	(a, b) = (a % 2, b % 2)
	print(a if a == b and (a == 0 or a == c) else -1)
main()


n = int(input())
sum_x = 0
sum_y = 0
odd_even = 0
odd_odd = 0
even_odd = 0
even_even = 0
for i in range(n):
	(x, y) = map(int, input().split())
	sum_x += x
	sum_y += y
	if x % 2 == 0 and y % 2 == 0:
		odd_odd += 1
	elif x % 2 == 0 and y % 2 == 1:
		odd_even += 1
	elif x % 2 == 1 and y % 2 == 0:
		even_odd += 1
	else:
		even_even += 1
if sum_x % 2 == 0 and sum_y % 2 == 0:
	print(0)
elif sum_x % 2 == 0 and sum_y % 2 == 1:
	print(-1)
elif sum_x % 2 == 1 and sum_y % 2 == 0:
	print(-1)
elif even_odd >= 1 or odd_even >= 1:
	print(1)
else:
	print(-1)


n = int(input())
(up, down) = ([], [])
for i in range(n):
	(x, y) = map(int, input().split())
	up.append(x)
	down.append(y)
(u, d) = (sum(up), sum(down))
if u % 2 == 0 and d % 2 == 0:
	print(0)
elif u % 2 != d % 2:
	print(-1)
elif u % 2 and d % 2:
	for (x, y) in zip(up, down):
		if x % 2 != y % 2:
			print(1)
			break
	else:
		print(-1)


n = int(input())
s1 = 0
s2 = 0
odd_even_pair = False
in_l1 = False
in_l2 = False
for _ in range(n):
	l = list(map(int, input().rstrip().split(' ')))
	s1 += l[0]
	s2 += l[1]
	if l[1] % 2 and (not l[0] % 2):
		odd_even_pair = True
		in_l2 = True
	if l[0] % 2 and (not l[1] % 2):
		odd_even_pair = True
		in_l1 = True
if s1 % 2 and s2 % 2:
	if odd_even_pair:
		print(1)
	else:
		print(-1)
elif s1 % 2 and (not s2 % 2):
	print(-1)
elif s2 % 2 and (not s1 % 2):
	print(-1)
else:
	print(0)


n = int(input())
a = b = 0
hr = False
hl = False
j = 0
for i in range(n):
	j += 1
	(x, y) = map(int, input().split())
	a += x
	b += y
	if (x + y) % 2 == 1:
		hr = True
if a % 2 == 0 and b % 2 == 0:
	print(0)
elif (a + b) % 2 == 0 and hr and (j > 1):
	print(1)
else:
	print(-1)


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	n = read_int()
	A = [0, 0]
	sx = 0
	sy = 0
	for i in range(n):
		(x, y) = read_ints()
		if abs(x - y) % 2:
			A[1] += 1
		else:
			A[0] += 1
		sx += x
		sy += y
	dbg(A, sx, sy)
	if (sx + sy) % 2:
		print(-1)
		return
	if sx % 2 == 0 or sy % 2 == 0:
		print(0)
		return
	if A[1]:
		print(1)
	else:
		print(-1)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def dbg(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections 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 read_int():
	return int(input())

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

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

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

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

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

def primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


n = int(input())
L = []
ol = 0
ou = 0
d = 0
for i in range(n):
	l = list(map(int, input().split()))
	L.append(l)
	e = 0
	o = 0
	if l[0] % 2 != 0:
		ol = ol + 1
		e = 1
	if l[1] % 2 != 0:
		ou = ou + 1
		o = 1
	if e != o:
		d = 1
if ol % 2 != 0 and ou % 2 != 0 and (d == 1):
	print(1)
elif ol % 2 == 0 and ou % 2 == 0:
	print(0)
else:
	print(-1)


sum1 = []
sum2 = []
need = 0
tr = 4
for i in range(int(input())):
	(n, k) = map(int, input().split())
	sum1.append(n)
	sum2.append(k)
if sum(sum1) % 2 == 0 == sum(sum2) % 2:
	print(0)
	tr += 1
elif sum(sum1) % 2 != 0 != sum(sum2) % 2:
	for i in range(len(sum1)):
		if sum1[i] % 2 != sum2[i] % 2:
			print(1)
			tr += 1
			break
if tr == 4:
	print(-1)


n = int(input())
l = []
(s1, s2) = (0, 0)
for i in range(n):
	(a, b) = map(int, input().split(' '))
	l.append([a, b])
	s1 += a
	s2 += b
if s1 % 2 == 0 and s2 % 2 == 0:
	print(0)
elif s1 % 2 == 0 and s2 % 2 != 0:
	print(-1)
elif s1 % 2 != 0 and s2 % 2 == 0:
	print(-1)
else:
	k = 0
	for t in l:
		if t[0] % 2 == 0 and t[1] % 2 != 0 or (t[0] % 2 != 0 and t[1] % 2 == 0):
			k = 1
	if k == 1:
		print(1)
	else:
		print(-1)


from math import *
from random import *
n = int(input())
flag = False
(A, B) = (0, 0)
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if a % 2 != b % 2:
		flag = True
	(A, B) = (A + a, B + b)
if A % 2 == 0 and B % 2 == 0:
	print(0)
elif A % 2 == 1 and B % 2 == 1 and flag:
	print(1)
else:
	print(-1)


n = int(input())
mr = 0
mc = 0
t = 0
mk = 0
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	mr += b
	mc += a
	mk += a + b
	if (a + b) % 2 == 1:
		t = t + 1
if mk % 2 == 1:
	print(-1)
elif mc % 2 == 0 and mr % 2 == 0:
	print(0)
elif mc % 2 == 1 and t > 0:
	print(1)
else:
	print(-1)


n = int(input())
odd = 0
x = y = 0
for i in range(n):
	(l, r) = map(int, input().split())
	x += l
	y += r
	if (l + r) % 2 != 0:
		odd += 1
if x % 2 == 0 and y % 2 == 0:
	print(0)
elif odd % 2 == 0 and n != 1 and (odd > 0):
	print(1)
else:
	print(-1)


n = int(input())
(sumx, sumy, check) = (0, 0, 0)
for i in range(n):
	(x, y) = map(int, input().split())
	sumx += x
	sumy += y
	if x % 2 != y % 2:
		check = 1
if sumx % 2 == 0 and sumy % 2 == 0:
	print(0)
elif sumx % 2 == 1 and sumy % 2 == 1 and (check == 1):
	print(1)
else:
	print(-1)


n = int(input())
up = []
down = []
sum1 = 0
sum2 = 0
check = 0
for i in range(0, n):
	(a, b) = map(int, input().split())
	if a % 2 != b % 2:
		check = 1
	sum1 = sum1 + a
	sum2 = sum2 + b
	up.append(a)
	down.append(b)
if sum1 % 2 == 0 and sum2 % 2 == 0:
	print(0)
elif sum1 % 2 != 0 and sum2 % 2 != 0 and (check == 1):
	print(1)
else:
	print(-1)


a = int(input())
c = []
d = []
for x in range(0, a):
	b = input().split()
	c.append(b[0])
	d.append(b[1])
s1 = 0
for y in range(0, a):
	s1 = s1 + int(c[y])
e1 = 0
if s1 % 2 == 0:
	e1 = 1
s2 = 0
for z in range(0, a):
	s2 = s2 + int(d[z])
e2 = 0
if s2 % 2 == 0:
	e2 = 1
if e1 == 1 and e2 == 1:
	print('0')
if e1 == 0 and e2 == 1:
	print('-1')
if e1 == 1 and e2 == 0:
	print('-1')
done = 0
if e1 == 0 and e2 == 0:
	for q in range(0, a):
		if int(c[q]) % 2 == 0 and int(d[q]) % 2 != 0:
			print('1')
			done = 1
			break
		if int(c[q]) % 2 != 0 and int(d[q]) % 2 == 0:
			print('1')
			done = 1
			break
	if done == 0:
		print('-1')


l = int(input())
top = []
bottom = []
min = 0
for i in range(l):
	(m, n) = map(int, input().split())
	top.append(m)
	bottom.append(n)
for i in range(l):
	if sum(top) % 2 == 0 and sum(bottom) % 2 == 0:
		print(min)
		exit()
	else:
		(top[i], bottom[i]) = (bottom[i], top[i])
		min = 1
print(-1)


n = int(input())
l = []
t = []
for _ in range(n):
	(x, y) = [int(x) for x in input().split()]
	l.append(x)
	t.append(y)
if sum(l) % 2 == 0 and sum(t) % 2 == 0:
	print(0)
	exit()
elif sum(l) % 2 != sum(t) % 2:
	print(-1)
	exit()
v = 0
for i in range(len(l)):
	if l[i] % 2 == 0 and t[i] % 2 != 0 or (l[i] % 2 != 0 and t[i] % 2 == 0):
		v = 1
		break
if v == 0:
	print(-1)
else:
	print(1)