William has two numbers $a$ and $b$ initially both equal to zero. William mastered performing three different operations with them quickly. Before performing each operation some positive integer $k$ is picked, which is then used to perform one of the following operations: (note, that for each operation you can choose a new positive integer $k$)

add number $k$ to both $a$ and $b$, or

add number $k$ to $a$ and subtract $k$ from $b$, or

add number $k$ to $b$ and subtract $k$ from $a$.

Note that after performing operations, numbers $a$ and $b$ may become negative as well.

William wants to find out the minimal number of operations he would have to perform to make $a$ equal to his favorite number $c$ and $b$ equal to his second favorite number $d$.


-----Input-----

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). Description of the test cases follows.

The only line of each test case contains two integers $c$ and $d$ $(0 \le c, d \le 10^9)$, which are William's favorite numbers and which he wants $a$ and $b$ to be transformed into.


-----Output-----

For each test case output a single number, which is the minimal number of operations which William would have to perform to make $a$ equal to $c$ and $b$ equal to $d$, or $-1$ if it is impossible to achieve this using the described operations.


-----Examples-----

Input
6
1 2
3 5
5 3
6 6
8 0
0 0
Output
-1
2
2
1
2
0


-----Note-----

Let us demonstrate one of the suboptimal ways of getting a pair $(3, 5)$:

Using an operation of the first type with $k=1$, the current pair would be equal to $(1, 1)$.

Using an operation of the third type with $k=8$, the current pair would be equal to $(-7, 9)$.

Using an operation of the second type with $k=7$, the current pair would be equal to $(0, 2)$.

Using an operation of the first type with $k=3$, the current pair would be equal to $(3, 5)$.

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
for _ in range(int(input())):
	(c, d) = map(int, input().split())
	if (c - d) % 2 == 1:
		print(-1)
	elif c == d == 0:
		print(0)
	elif c == d:
		print(1)
	else:
		print(2)


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

def main():

	def solve():
		(c, d) = map(int, input().split())
		ans = 2
		if not c and (not d):
			ans = 0
		elif c == d:
			ans = 1
		elif (c & 1) + (d & 1) == 1:
			ans = -1
		return ans
	t = int(input())
	for i in range(t):
		print(solve())
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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


read_integer = lambda : int(input().strip())
read_list = lambda : list(map(int, input().strip().split()))

def operations(a, b):
	if (a + b) % 2 == 1:
		return -1
	if a == b:
		if a == 0:
			return 0
		return 1
	else:
		return 2
t = read_integer()
ans = []
for _ in range(t):
	(ca, cb) = read_list()
	ans.append(operations(ca, cb))
print('\n'.join(list(map(str, ans))))


import queue
from math import *
import sys
from collections import *
from random import *
sys.setrecursionlimit(99999)
eps = sys.float_info.epsilon
P = 2
INF = 1000000000.0 + 1
MOD = 1000000007

def is_prime(n):
	if n == 0 or n == 1:
		return False
	d = 2
	while d * d <= n:
		if n % d == 0:
			return False
		d += 1
	return True

def div_up(n, k):
	if n % k == 0:
		return n // k
	else:
		return n // k + 1

def num_len(n, base):
	if n == 0:
		return 1
	return int(floor(log(n, base) + 1))

def dfs_sample(graph, cl, p, v):
	cl[v] = 1
	for to in graph[v]:
		if cl[to] == 1 and p[v] != to:
			pass
		elif cl[to] == 0:
			p[to] = v
			dfs_sample(graph, cl, p, to)
	cl[v] = 2

def down(a):
	for i in range(1, len(a)):
		if a[i] > a[i - 1]:
			return False
	return True

def up(a):
	for i in range(1, len(a)):
		if a[i] < a[i - 1]:
			return False
	return True

def code(c):
	return ord(c) - 32

def _hash_(s):
	(res, p) = (0, 1)
	for i in range(len(s)):
		res += code(s[i]) * p
		res %= MOD
		p *= P
		p %= MOD
	return res % MOD

def remove_edge(v, u, graph):
	graph[v].remove(u)
	graph[u].remove(v)

def dfs_stack(start, graph, visited):
	global b
	stack = []
	visited[start] = True
	stack.append(start)
	while len(stack) != 0:
		v = stack.pop()
		for to in graph[v]:
			if not visited[to]:
				visited[to] = True
				stack.append(to)

def solve():
	(c, d) = map(int, input().split())
	if c == d == 0:
		print(0)
		return
	if abs(c - d) % 2 != 0:
		print(-1)
	elif c == d:
		print(1)
	else:
		print(2)
for _ in range(int(input())):
	solve()

def debug():
	pass


tt = int(input())
arrow = []
while tt > 0:
	w = input()
	w = w.split()
	a = int(w[0])
	b = int(w[1])
	s = abs(a - b)
	if a == b and a != 0:
		ans = 1
	elif a == b:
		ans = 0
	elif s % 2 == 0:
		ans = 2
	else:
		ans = -1
	arrow.append(ans)
	tt -= 1
for i in range(len(arrow)):
	print(arrow[i])


for t in range(int(input())):
	(c, d) = map(int, input().split())
	if abs(c - d) % 2 == 1:
		print('-1')
	elif c == 0 and d == 0:
		print('0')
	elif c == d:
		print('1')
	else:
		print('2')


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


for i in range(int(input())):
	(x, y) = input().split(' ')
	x = int(x)
	y = int(y)
	if x == 0 and y == 0:
		print(0)
	elif x == y:
		print(1)
	elif (x - y) % 2 != 0:
		print(-1)
	else:
		print(2)


for _ in range(int(input())):
	(c, d) = list(map(int, input().split()))
	if abs(c - d) % 2 == 1:
		print(-1)
	elif c == 0 and d == 0:
		print(0)
	elif c == 0 or d == 0:
		print(2)
	elif c == d:
		print(1)
	else:
		print(2)


(a, b) = (0, 0)
n = int(input())
lst = [[int(i) for i in input().split(' ')] for r in range(n)]
for i in range(n):
	(c, d) = sorted(lst[i], reverse=True)
	(a, b) = (0, 0)
	if c == 0 and d == 0:
		print(0)
		continue
	delta = c - d
	if delta == 0:
		print(1)
	elif delta % 2 == 0:
		print(2)
	else:
		print(-1)


n = int(input())
r = []
for i in range(n):
	ans = 0
	nums = input().split()
	a = int(nums[0])
	b = int(nums[1])
	avr = (a + b) / 2
	if (a - b) % 2 == 1:
		r.append(-1)
	elif a == 0 and b == 0:
		r.append(0)
	elif a == b:
		r.append(1)
	else:
		r.append(2)
for n in r:
	print(n)


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


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(tx, ty) = map(int, input().split())
	if (tx + ty) % 2 != 0:
		print(-1)
		continue
	if tx == ty == 0:
		print(0)
	elif tx == ty:
		print(1)
	else:
		print(2)


import sys
input = sys.stdin.readline

def solve():
	(c, d) = map(int, input().split())
	if c == d:
		return 0 if c == 0 else 1
	elif (c + d) % 2 == 0:
		return 2
	else:
		return -1
for _ in range(int(input())):
	print(solve())


for i in range(int(input())):
	(h, l) = map(int, input().split(' '))
	if h == 0 and l == 0:
		print('0')
	elif h == l:
		print('1')
	elif abs(h - l) % 2 == 1:
		print('-1')
	else:
		print('2')


rez = []
t = int(input())
for ti in range(t):
	(c, d) = map(int, input().split())
	r = c - d
	if r % 2 == 1:
		rez += [-1]
	elif c == 0 and d == 0:
		rez += [0]
	elif abs(c) == abs(d):
		rez += [1]
	else:
		rez += [2]
for i in rez:
	print(i)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
import math as mt
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

def main():
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		z = (a + b) // 2
		if abs(a - z) != abs(b - z):
			print(-1)
		elif a == b == 0:
			print(0)
		elif a == z:
			print(1)
		else:
			print(2)
	return
main()


def min_op(a, b):
	if a == 0 and b == 0:
		return 0
	if a % 2 != b % 2:
		return -1
	if a == b:
		return 1
	else:
		return 2
n = int(input())
lst = []
for item in range(n):
	lst.append(min_op(*map(int, input().split())))
print(*lst, sep='\n')


for _ in range(int(input())):
	(c, d) = map(int, input().split())
	if (c - d) % 2 == 1:
		print(-1)
		continue
	if c == d:
		if c == 0:
			print(0)
			continue
		print(1)
		continue
	print(2)


import sys
x = sys.stdin.readline()
for line in sys.stdin:
	numbers = line.split()
	c = int(numbers[0])
	d = int(numbers[1])
	if c == 0 and d == 0:
		print(0)
	elif c == d:
		print(1)
	elif (c - d) % 2 != 0:
		print(-1)
	else:
		print(2)


import sys, math

def solve():
	(a, b) = map(int, input().split())
	n = abs(a - b)
	if n % 2 == 0:
		if a == b:
			if a == 0:
				print(0)
			else:
				print(1)
		else:
			print(2)
	else:
		print(-1)
t = int(input())
while t != 0:
	solve()
	t -= 1


t = int(input())
for i in range(t):
	(a, b) = (int(x) for x in input().split())
	if abs(a + b) % 2 == 1:
		print(-1)
		continue
	if a == 0 and b == 0:
		print(0)
		continue
	if a == b:
		print(1)
		continue
	print(2)


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


def main():
	(c, d) = map(int, input().split())
	if (c + d) % 2 == 1:
		return -1
	elif c == d:
		if c != 0:
			return 1
		else:
			return 0
	return 2
N = int(input())
for i in range(N):
	res = main()
	print(res)


import os, sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd
from _collections import deque
import heapq as hp
from bisect import bisect_left, bisect_right
from math import cos, sin
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(c, d) = map(int, input().split())
	if c == d == 0:
		print(0)
	elif abs(c - d) % 2:
		print(-1)
	elif c == d:
		print(1)
	else:
		print(2)


import sys
testcases = int(sys.stdin.readline())
for case in range(testcases):
	(c, d) = [int(x) for x in sys.stdin.readline().strip().split(' ')]
	if (c - d) % 2 != 0:
		print(-1)
		continue
	if c == 0 and d == 0:
		print(0)
		continue
	if c == d:
		print(1)
		continue
	print(2)


import math
import heapq
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	(c, d) = M()
	if c == d and c == 0:
		print(0)
	elif c == d:
		print(1)
	elif abs(c - d) % 2 == 1:
		print(-1)
	else:
		print(2)


def solve():
	(c, d) = map(int, input().split())
	dif = abs(c - d)
	if c == 0 and d == 0:
		print(0)
	elif c + d == 0 or dif == 0:
		print(1)
	elif dif % 2 == 0:
		print(2)
	else:
		print(-1)
t = int(input())
for _ in range(t):
	solve()


casos = int(input())
cont = 0
while cont != casos:
	cont += 1
	cadena = str(input())
	lista = cadena.split(' ')
	lista[0] = int(lista[0])
	lista[1] = int(lista[1])
	if max(lista) == 0 and min(lista) == 0:
		print('0')
	else:
		dif = max(lista) - min(lista)
		if dif % 2 == 0:
			if dif == 0:
				print('1')
			elif dif != 0:
				print('2')
		else:
			print('-1')


import math
import os
import sys
from io import BytesIO, IOBase
M = 1000000007
import random
import heapq
import bisect
import time
from functools import lru_cache
from collections import *
from itertools import *
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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

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

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

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

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

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

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

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def main():
	t = 1
	t = inpu()
	for _ in range(t):
		(a, b) = sep()
		if a == 0 and b == 0:
			print(0)
			continue
		if a == b:
			print(1)
			continue
		if abs(a - b) % 2 != 0:
			print(-1)
			continue
		else:
			print(2)
main()


import sys
input = sys.stdin.readline
INF = int(1000000000.0) + 7
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]

def solve():
	(n, m) = map(int, input().split())
	if (n + m) % 2 == 1:
		print(-1)
	elif n == 0 and m == 0:
		print(0)
	elif n == m:
		print(1)
	else:
		print(2)
t = int(input())
while t:
	t -= 1
	solve()


number = int(input())
arr = [[int(i) for i in input().split()] for i in range(number)]
for line in arr:
	if line[0] == line[1] == 0:
		print(0)
	elif line[0] == line[1]:
		print(1)
	elif (max(line[0], line[1]) - min(line[0], line[1])) % 2 == 0:
		print(2)
	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')
from math import gcd
for _ in range(int(input())):
	(c, d) = map(int, input().split())
	if c == 0 and d == 0:
		print(0)
		continue
	if (c + d) % 2 == 0:
		if c == d:
			print(1)
		else:
			print(2)
	else:
		print(-1)


import os
import sys
from collections import Counter
from itertools import *
from io import BytesIO, IOBase

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

def sieve():
	global spf, adj, MAXN
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(2, MAXN):
		if i * i > MAXN:
			break
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def getdistinctFactorization(n):
	global adj, spf, MAXN
	for i in range(1, n + 1):
		index = 1
		x = i
		if x != 1:
			adj[i].append(spf[x])
		x = x // spf[x]
		while x != 1:
			if adj[i][index - 1] != spf[x]:
				adj[i].append(spf[x])
				index += 1
			x = x // spf[x]

def printDivisors(n):
	i = 2
	z = [1, n]
	while i <= sqrt(n):
		if n % i == 0:
			if n / i == i:
				z.append(i)
			else:
				z.append(i)
				z.append(n // i)
		i = i + 1
	return z

def create(n, x, f):
	pq = len(bin(n)[2:])
	if f == 0:
		tt = min
	else:
		tt = max
	dp = [[inf] * n for _ in range(pq)]
	dp[0] = x
	for i in range(1, pq):
		for j in range(n - (1 << i) + 1):
			dp[i][j] = tt(dp[i - 1][j], dp[i - 1][j + (1 << i - 1)])
	return dp

def enquiry(l, r, dp, f):
	if l > r:
		return inf if not f else -inf
	if f == 1:
		tt = max
	else:
		tt = min
	pq1 = len(bin(r - l + 1)[2:]) - 1
	return tt(dp[pq1][l], dp[pq1][r - (1 << pq1) + 1])

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

def main():
	for _ in range(int(input())):
		(x, y) = map(int, input().split())
		if x == y == 0:
			print(0)
		elif x == y:
			print(1)
		elif (x + y) % 2 == 0:
			print(2)
		else:
			print(-1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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


import sys
import math
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
for t in range(int(input())):
	(a, b) = intInp()
	if a == 0 and b == 0:
		print(0)
	elif a == b:
		print(1)
	elif (a + b) % 2 == 0:
		print(2)
	else:
		print(-1)


t = int(input())
while t > 0:
	(c, d) = map(int, input().split())
	if (c + d) % 2 == 1:
		print(-1)
	elif c == 0 and d == 0:
		print(0)
	elif c == d or c == d * -1:
		print(1)
	else:
		print(2)
	t -= 1


import sys
from sys import stdin
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
	(a, b) = (0, 0)
	(c, d) = map(int, stdin.readline().split())
	if a == c and b == d:
		ANS.append('0')
	elif (a - b) % 2 != (c - d) % 2:
		ANS.append('-1')
		continue
	elif abs(a - c) == abs(b - d):
		ANS.append('1')
	else:
		ANS.append('2')
print('\n'.join(ANS))


for s in [*open(0)][1:]:
	(c, d) = map(int, s.split())
	print((2 * (c != d) or +(c > 0), -1)[c + d & 1])


def check(c, d):
	a = b = 0
	count = 0
	if (c - d) % 2 != 0:
		return -1
	elif c == 0 and d == 0:
		return 0
	elif c == -d or c == d:
		return 1
	else:
		return 2
n = int(input())
list = []
for i in range(n):
	(m, n) = input().split(' ')
	list.append(check(int(m), int(n)))
for j in list:
	print(j)


def function(a, b):
	if a != b:
		if (a + b) % 2 == 1:
			return '-1'
		else:
			return '2'
	elif a != 0:
		return '1'
	else:
		return '0'
t = int(input())
list = []
for i in range(t):
	list.append(input().split())
for items in list:
	print(function(int(items[0]), int(items[1])))


from sys import stdin
read = lambda : stdin.readline()
for _ in range(int(read())):
	(c, d) = map(int, read().split())
	if c == d == 0:
		print(0)
		continue
	if abs(c - d) % 2 == 1:
		print(-1)
		continue
	if c < 0 and d < 0:
		print(-1)
		continue
	if abs(c) == abs(d):
		print(1)
		continue
	else:
		print(2)
		continue


t = int(input())
for i in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if (b - a) % 2 == 1:
		print(-1)
	elif a == b:
		if a == 0:
			print(0)
		else:
			print(1)
	else:
		print(2)


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


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 and b == 0:
		print(0)
		continue
	if a == b:
		print(1)
		continue
	if abs(b - a) % 2 == 0:
		print(2)
		continue
	print(-1)


import collections
import math
import itertools
import sys
import time

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

def ints_input():
	return list((int(x) for x in input().split()))

def int_input():
	return int(input())

def solve():
	(c, d) = ints_input()
	if c == d == 0:
		print(0)
	elif c == d:
		print(1)
	elif c % 2 == d % 2:
		print(2)
	else:
		print(-1)
if True:
	for _ in range(int_input()):
		solve()
else:
	solve()


t = int(input())
ans = []
for _ in range(t):
	(c, d) = [int(x) for x in input().split()]
	if c == d:
		ans.append('0' if c == 0 else '1')
	elif c & 1 == d & 1:
		ans.append('2')
	else:
		ans.append('-1')
print('\n'.join(ans))


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	while t:
		t -= 1
		(a, b) = map(int, input().split())
		if (a + b) % 2 == 1:
			print(-1)
		elif a == 0 and b == 0:
			print(0)
		elif a == b:
			print(1)
		else:
			print(2)
main()


for _ in range(int(input())):
	(c, d) = map(int, input().split())
	diff = abs(c - d)
	if diff == 0 and c != 0:
		ans = 1
	elif diff == 0 and c == 0:
		ans = 0
	elif (c + d) % 2 == 0:
		ans = 2
	else:
		ans = -1
	print(ans)


n = int(input())
a1 = []
a2 = []
for i in range(0, n):
	a = list(map(int, input().strip().split()))
	a1.append(a)
for i in range(0, n):
	x = int(a1[i][0] + a1[i][1])
	if x % 2 == 0 and a1[i][0] != a1[i][1]:
		a2.append(2)
	elif x % 2 != 0 and a1[i][0] != a1[i][1]:
		a2.append(-1)
	elif a1[i][0] == a1[i][1] and a1[i][0] == 0 and (a1[i][1] == 0):
		a2.append(0)
	elif a1[i][0] == a1[i][1] and a1[i][0] != 0 and (a1[i][1] != 0):
		a2.append(1)
for i in range(0, n):
	print(a2[i])


def King_Aurther():
	(a, b) = map(int, input().split())
	if a == 0 and b == 0:
		print('0')
		return
	elif a == b:
		print('1')
	elif abs(a - b) % 2 == 0:
		print('2')
	else:
		print('-1')

def main():
	Test_case = int(input())
	for x in range(Test_case):
		King_Aurther()
main()


import math
import sys
import collections
import bisect
import time
import random
import itertools
import string
from collections import Counter, defaultdict

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

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

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	(a, b) = get_ints()
	if abs(a - b) % 2 == 1:
		print(-1)
	elif a == b == 0:
		print(0)
	elif abs(a) == abs(b):
		print(1)
	else:
		print(2)


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


t = int(input())
l = []
for i in range(t):
	(a, b) = map(int, input().split())
	l.append(a)
	l.append(b)
for i in range(0, len(l), 2):
	a = min(l[i], l[i + 1])
	b = max(l[i], l[i + 1])
	r = b - a
	if a == 0 and b == 0:
		print(0)
	elif r == 0:
		print(1)
	elif r % 2 == 0:
		print(2)
	elif r % 2 == 1:
		print(-1)


testcases = int(input())
for tc in range(testcases):
	(a, b) = list(map(int, input().split()))
	if a == b and a == 0:
		print(0)
		continue
	if a == b:
		print(1)
		continue
	elif abs(a - b) % 2 == 0:
		print(2)
	else:
		print(-1)


import sys
from os import path
a = int(sys.stdin.readline())
for i in range(a):
	b = sys.stdin.readline()
	de_array = [int(x) for x in b.replace('\n', '').split(' ')]
	if de_array[0] == de_array[1]:
		if de_array[0] == 0:
			print(0)
		else:
			print(1)
	elif abs(de_array[0] - de_array[1]) % 2 == 0:
		print(2)
	else:
		print(-1)


t = int(input())
while t != 0:
	count = 0
	(c, d) = map(int, input().split())
	a = 0
	b = 0
	k = 0
	if c == d:
		if c == 0:
			print(0)
			t -= 1
			continue
		else:
			print(1)
			t -= 1
			continue
	if (c + d) % 2 != 0:
		print(-1)
	else:
		a = (c + d) // 2
		b = (c + d) // 2
		count += 1
		k = (c - d) // 2
		if abs(k) == abs(int(k)):
			count += 1
			print(count)
		else:
			print(-1)
	t -= 1


size = int(input())
matrix = []
for x in range(size):
	matrix.append([int(y) for y in input().split()])
for x in range(size):
	if matrix[x][0] == 0 and matrix[x][1] == 0:
		print(0)
	elif matrix[x][0] % 2 != matrix[x][1] % 2:
		print(-1)
	elif matrix[x][0] == matrix[x][1] and matrix[x][0] != 0 and (matrix[x][1] != 0):
		print(1)
	else:
		print(2)


t = int(input())
l = []
for i in range(t):
	k = 0
	(c, d) = map(int, input().split())
	if c == 0 and d == 0:
		l.append('0')
	elif c == d:
		l.append('1')
	elif (c - d) % 2 == 1:
		l.append('-1')
	else:
		l.append('2')
for a in range(len(l)):
	print(l[a])


for _ in range(int(input())):
	(c, d) = [int(x) for x in input().split()]
	if abs(c - d) % 2 != 0:
		print(-1)
	elif c == 0 and d == 0:
		print(0)
	elif c == d:
		print(1)
	else:
		print(2)


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


cases = int(input())
for z in range(cases):
	(a, b) = map(int, input().split(' '))
	if a == 0 and b == 0:
		print(0)
		continue
	if a == b:
		print(1)
		continue
	if abs(a - b) % 2 == 0:
		print(2)
	else:
		print(-1)


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
ANS = []
input = stdin.readline

def solve():
	pass
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		if a == 0:
			print(0)
		else:
			print(1)
	elif abs(a - b) % 2 == 1:
		print(-1)
	else:
		print(2)
print('\n'.join(ANS))


testCase = int(input())
for i in range(testCase):
	my_list = input().split()
	(a, b) = (0, 0)
	c = int(my_list[0])
	d = int(my_list[1])
	if d > c:
		(c, d) = (d, c)
	count = 0
	while count < c - d + 2:
		if c == d:
			break
		count += 1
		haf_def = int((c - d) / 2)
		c -= haf_def
		d += haf_def
	if count >= 0 and c > 0:
		count += 1
	if c == d:
		print(count)
	else:
		print(-1)


import math
t = int(input())
for w in range(t):
	(c, d) = [int(x) for x in input().split()]
	if (max(c, d) - min(c, d)) % 2 != 0:
		print(-1)
	elif c == d:
		if c == 0:
			print(0)
		else:
			print(1)
	else:
		print(2)


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


for _ in [*open(0)][1:]:
	(c, d) = map(int, _.split())
	if (c + d) % 2:
		print(-1)
	elif c != d:
		print(2)
	elif c != 0:
		print(1)
	else:
		print(0)


import sys
import math
for i in range(int(input())):
	(c, d) = list(map(int, input().split()))
	if abs(c - d) % 2 != 0:
		print(-1)
	elif c == d:
		if c == 0:
			print(0)
		else:
			print(1)
	else:
		print(2)


import math
t = int(input())
for i in range(t):
	(c, d) = map(int, input().split())
	if c == 0 and d == 0:
		print(0)
	elif c == d:
		print(1)
	elif (c + d) / 2 == math.floor((c + d) / 2):
		print(2)
	else:
		print(-1)


def operation(li):
	for item in li:
		if item[1] == 0 and item[0] == 0:
			print('0')
			continue
		if item[1] == item[0]:
			print('1')
			continue
		elif item[1] > item[0]:
			ans = item[1] - item[0]
		elif item[1] < item[0]:
			ans = item[0] - item[1]
		if ans % 2 == 0:
			print('2')
		elif ans % 2 == 1:
			print('-1')
n = int(input())
li = []
for i in range(n):
	li.append([int(x) for x in input().strip().split()][:2])
operation(li)


t = int(input())
r = []
for i in range(t):
	cd = list(map(int, input().split()))
	c = cd[0]
	d = cd[1]
	if c == 0 and d == 0:
		r.append(0)
	elif abs(c - d) == 0:
		r.append(1)
	elif abs(c - d) % 2 == 0:
		r.append(2)
	else:
		r.append(-1)
print(*r, sep='\n')


import sys
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
test_case = inp()
current_test = 0
while current_test < test_case:
	current_test += 1
	(c, d) = invr()
	if c == 0 and d == 0:
		print(0)
	elif c == d:
		print(1)
	elif c % 2 == 0 and d % 2 == 0 or (c % 2 != 0 and d % 2 != 0):
		print(2)
	else:
		print(-1)


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


for ii in range(int(input())):
	(a, b) = map(int, input().split())
	r = abs(a - b)
	if a == b == 0:
		print(0)
	elif a == b:
		print(1)
	elif r % 2:
		print(-1)
	else:
		print(2)


def main(c, d):
	if c == 0 and d == 0:
		return 0
	if (c + d) % 2 != 0:
		return -1
	if c == d:
		return 1
	return 2
for _ in range(int(input())):
	(c, d) = map(int, input().split())
	print(main(c, d))


import sys

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for i in range(t):
	temp = inlt()
	c = temp[0]
	d = temp[1]
	if (c + d) % 2 == 1:
		print('-1')
		continue
	if c == 0 and d == 0:
		print('0')
		continue
	if c == d:
		print('1')
		continue
	print('2')


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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

class Stack:

	def __init__(self):
		self.items = []

	def push(self, item):
		self.items.append(item)

	def pop(self):
		return self.items.pop()

	def empty(self):
		return self.items == []

	def size(self):
		return len(self.items)

	def at(self, idx):
		try:
			return self.items[idx]
		except:
			return -1

class priority_queue(object):

	def __init__(self):
		self.queue = []

	def __str__(self):
		return ' '.join([str(i) for i in self.queue])

	def empty(self):
		return len(self.queue) == 0

	def insert(self, data):
		self.queue.append(data)

	def delete(self):
		try:
			max = 0
			for i in range(len(self.queue)):
				if self.queue[i] > self.queue[max]:
					max = i
			item = self.queue[max]
			del self.queue[max]
			return item
		except IndexError:
			print()
			exit()
mod = int(1000000000.0 + 7)
imin = -2147483648
imax = 2147483647
true = True
false = False
N = int(100000.0 + 9)
none = None
inp = lambda : input()
I = lambda : int(inp())
M = lambda : map(int, inp().split())
MS = lambda : map(str, inp().split())
S = lambda : list(MS())
L = lambda : list(M())
Yes = lambda : print('Yes')
No = lambda : print('No')
YES = lambda : print('YES')
NO = lambda : print('NO')
yes = lambda : print('yes')
no = lambda : print('no')
chartonum = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '0': 0}

def IO(controll):
	if controll == false:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('uttar.txt', 'w')
	else:
		pass

def true_yes(statement):
	return YES() if statement else NO()

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

def state(statement, one, two):
	print(one if statement else two)

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

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

def prec(a):
	return '{0:.9f}'.format(a)

def case(t):
	print('Case #' + str(i) + ': ', end='')

def palin(s):
	return s == s[::-1]

def is_sorted(arr):
	return arr == sorted(arr)
IO(1)

def kabraji_ka_totka():
	(a, b) = L()
	if a == 0 and b == 0:
		print(0)
		return
	if a > b:
		(a, b) = (b, a)
	diff = b - a
	if diff % 2:
		print(-1)
	elif diff == 0:
		print(1)
	else:
		print(2)
for i in range(I()):
	kabraji_ka_totka()


t = int(input())
for j in range(t):
	(x, y) = input().split(' ')
	x = int(x)
	y = int(y)
	if x == 0 and y == 0:
		print(0)
	elif x == y:
		print(1)
	elif (x - y) % 2 != 0:
		print(-1)
	else:
		print(2)


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

def solve(s):
	L = s.split()
	c = int(L[0])
	d = int(L[1])
	if (c + d) % 2 != 0:
		print(-1)
	elif c == 0 and d == 0:
		print(0)
	elif c == d or c == -d:
		print(1)
	else:
		print(2)
tot = int(input())
for i in range(tot):
	solve(input())


t = int(input())
while t > 0:
	a = b = 0
	(c, d) = map(int, input().split())
	cnt = 0
	if c == 0 and d == 0:
		print(0)
	elif c == d and c != 0:
		print(1)
	elif abs(c - d) % 2 == 0:
		print(2)
	elif abs(c - d) % 2 != 0:
		print(-1)
	t -= 1


result = ''
for r in range(0, int(input())):
	string = input()
	c = int(string.split()[0])
	d = int(string.split()[1])
	if c == 0 and d == 0:
		result += '0\n'
	elif c == d:
		result += '1\n'
	elif (c + d) % 2 != 0:
		result += '-1\n'
	else:
		result += '2\n'
print(result.rstrip('\n'))


n = int(input())
a1 = []
b1 = []
for i in range(n):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	a1.append(a)
	b1.append(b)
for i in range(n):
	if a1[i] == 0 and b1[i] == 0:
		print(0)
	elif a1[i] == b1[i] or a1[i] + b1[i] == 0:
		print(1)
	elif (a1[i] + b1[i]) % 2 == 1:
		print(-1)
	else:
		print(2)


t = int(input())
while t > 0:
	t -= 1
	ip = input().split()
	(c, d) = [int(i) for i in ip]
	if c == d == 0:
		print('0')
	elif c == d:
		print('1')
	elif (c + d) % 2 == 0:
		print('2')
	else:
		print('-1')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 2
	if (a + b) % 2:
		ans -= 3
	else:
		if not a + b:
			ans -= 1
		if not a - b:
			ans -= 1
	print(ans)


k = int(input())
a = 0
b = 0
mas = []
for i in range(k):
	(c, d) = map(int, input().split())
	if c == 0 and d == 0:
		mas.append(0)
	elif c == d:
		mas.append(1)
	elif abs(c - d) % 2 == 0:
		mas.append(2)
	else:
		mas.append(-1)
print(*mas, sep='\n')


class Dsu:

	def __init__(self, n):
		self.parent = list(range(n))
		self.rank = [1] * n

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

	def union(self, x, y):
		(px, py) = (self.find(x), self.find(y))
		if px == py:
			return 0
		if self.rank[py] > self.rank[px]:
			(px, py) = (py, px)
		self.parent[py] = px
		self.rank[px] += self.rank[py]
		return 1

	def get_size(self, x):
		return self.rank[self.find(x)]

class SegTree:

	def __init__(self, n, array):
		self.n = n
		self.tree = [0] * (2 * n)
		for i in range(n, 2 * n):
			self.tree[i] = array[i - n]
		for i in range(n - 1, -1, -1):
			self.tree[i] = self.tree[2 * i] + self.tree[2 * i + 1]

	def update(self, i, val):
		self.tree[i] = val
		while i:
			self.tree[i] = self.tree[i * 2] + self.tree[i * 2 + 1]
			i //= 2

	def query(self):
		pass

	def top(self):
		return self.tree[0]
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from math import ceil, floor, log, gcd, sqrt
from collections import Counter, deque
from heapq import heappush, heappop, heapify

def re():
	return stdin.readline().rstrip()

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

def test(cases):
	for _ in range(cases):
		solve()
mod = 1000000007
inf = 1e+18
nl = '\n'

def solve():
	(a, b) = ints()
	if a == 0 and b == 0:
		print(0)
	elif a == b:
		print(1)
	elif abs(a - b) % 2:
		print(-1)
	else:
		print(2)
	return
test(int(re()))


for i in range(int(input())):
	(c, d) = map(int, input().split())
	if abs(c - d) % 2 == 1:
		print(-1)
		continue
	if c == 0 and d == 0:
		print(0)
		continue
	if c == d:
		print(1)
		continue
	print(2)


def solve(a, b):
	if (a + b) % 2:
		return -1
	if a == b == 0:
		return 0
	if a + b == 0 or a == b:
		return 1
	return 2
import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	print(solve(a, b))


arr = []
for i in range(int(input())):
	arr.append([int(x) for x in input().split()])
for i in arr:
	if i == [0, 0]:
		print('0')
	elif i[0] - i[1] == 0:
		print('1')
	elif (i[0] - i[1]) % 2 != 0:
		print('-1')
	elif (i[0] - i[1]) % 2 == 0:
		print('2')


N = int(input())
while N > 0:
	Arr = list(map(int, input().split()))
	A = Arr[0]
	B = Arr[1]
	if A == 0 and B == 0:
		print(0)
	elif A == B:
		print(1)
	elif (A - B) % 2 == 0:
		print(2)
	else:
		print(-1)
	N -= 1


import sys
testcases = int(input())
while testcases > 0:
	(c, d) = map(int, sys.stdin.readline().split())
	if abs(c - d) % 2 != 0:
		print(-1)
	elif c == d == 0:
		print(0)
	elif c == d != 0:
		print(1)
	else:
		print(2)
	testcases -= 1


x = int(input())
for a in range(x):
	(q, w) = map(int, input().split())
	if q % 2 != w % 2:
		print(-1)
	elif q != w:
		print(2)
	elif q == 0:
		print(0)
	else:
		print(1)


n = int(input())
for i in range(n):
	[c, d] = input().split()
	c = int(c)
	d = int(d)
	if (c + d) % 2 != 0 and abs(c - d) % 2 != 0:
		print('-1')
	elif c == 0 and d == 0:
		print('0')
	elif c == d:
		print('1')
	else:
		print('2')


import sys

def solve(a, b):
	if (a + b) % 2:
		return -1
	if a == b == 0:
		return 0
	if abs(a) == abs(b):
		return 1
	else:
		return 2
for _ in range(int(sys.stdin.readline())):
	(a, b) = map(int, sys.stdin.readline().split())
	print(solve(a, b))


import sys
import math
from collections import Counter
import operator
import heapq
import bisect
t = int(input())
for _ in range(t):
	(c, d) = map(int, input().split())
	if c == d:
		print(1 if c != 0 else 0)
	elif abs(c - d) % 2 == 0:
		print(2)
	else:
		print(-1)


c = int(input())
for i in range(c):
	strs = input().split(' ')
	a = int(strs[0])
	b = int(strs[1])
	if a == b:
		if a == 0:
			print(0)
		else:
			print(1)
	elif (a - b) % 2 == 0:
		print(2)
	else:
		print(-1)


def process(c, d):
	if (c + d) % 2 != 0:
		return -1
	if c == 0 and d == 0:
		return 0
	if c == d:
		return 1
	return 2
t = int(input())
for i in range(t):
	(c, d) = [int(x) for x in input().split()]
	print(process(c, d))


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve(a, b):
	if a == 0 and b == 0:
		return 0
	d = abs(a - b)
	if d % 2 == 1:
		return -1
	return 1 if d == 0 else 2
TC = int(input())
for tc in range(TC):
	(a, b) = map(int, input().split())
	res = solve(a, b)
	print(res)


def func(a, b):
	if a == 0 and b == 0:
		print(0)
	elif a == b and a > 0:
		print(1)
	elif abs(a - b) % 2 == 0:
		print(2)
	elif abs(a - b) % 2 == 1 or (a == b and a < 0):
		print(-1)
t = int(input())
for i in range(t):
	lst = list(map(int, input().split()))
	func(lst[0], lst[1])


import sys
data_num = sys.stdin.readline()
cd_set = []
for each in range(int(data_num)):
	cd = list(input().split())
	for i in range(2):
		cd[i] = int(cd[i])
	cd_set.append(cd)
output_set = []
for cd in cd_set:
	(a, b, c, d) = (0, 0, cd[0], cd[1])
	k = (c + d) / 2
	if c == d and c == 0:
		output_set.append(0)
	elif k % 1 != 0:
		output_set.append(-1)
	else:
		(a, b) = (k, k)
		if a == c and b == d:
			output_set.append(1)
		else:
			output_set.append(2)
for each in output_set:
	print(each)


import sys
input = sys.stdin.readline

def sv(c, d):
	if c == d == 0:
		return 0
	if c == d:
		return 1
	if (c + d) % 2 == 0:
		return 2
	else:
		return -1

def main():
	for _ in range(int(input())):
		(c, d) = map(int, input().split())
		print(sv(c, d))
main()


t = int(input())
for k in range(t):
	(a, b) = map(int, input().split())
	c = (a + b) / 2
	if c == int(c) and b != a:
		print(2)
	elif b == a and b != 0:
		print(1)
	elif a == 0 and b == 0:
		print(0)
	else:
		print(-1)


def num():
	(c, d) = input().split()
	c = int(c)
	d = int(d)
	if c == 0 and d == 0:
		print(0)
	elif c == d:
		print(1)
	elif (c + d) % 2 == 0:
		print(2)
	else:
		print(-1)
t = int(input())
while t:
	num()
	t = t - 1


import sys

def rall():
	return sys.stdin.readlines()

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

def rl_types(types):
	str_list = [x for x in sys.stdin.readline().strip().split(' ')]
	return [types[i](str_list[i]) for i in range(len(str_list))]

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

def pra(array):
	sys.stdout.write(' '.join([str(x) for x in array]) + '\n')

def solve(array):
	return array
NT = int(rl())
for ti in range(NT):
	(a, b) = [int(x) for x in rl().split(' ')]
	if a == 0 and b == 0:
		pr(0)
	elif a == b:
		pr(1)
	elif abs(a - b) % 2 == 0:
		pr(2)
	else:
		pr(-1)


def main():
	t = int(input())
	a = [None for _ in range(t)]
	b = [None for _ in range(t)]
	for i in range(t):
		(a[i], b[i]) = map(int, input().split())
	ans = [None for _ in range(t)]
	for i in range(t):
		if (a[i] + b[i]) % 2 != 0:
			ans[i] = -1
		elif a[i] == 0 and b[i] == 0:
			ans[i] = 0
		elif a[i] == b[i]:
			ans[i] = 1
		else:
			ans[i] = 2
	for x in ans:
		print(x)
main()


for s in [*open(0)][1:]:
	(c, d) = map(int, s.split())
	if abs(c - d) % 2 != 0:
		print('-1')
		continue
	if c == 0 and d == 0:
		print('0')
	elif c == d:
		print('1')
	elif c != d:
		print('2')


def solve(a, b):
	if a == b == 0:
		return 0
	if (a + b) % 2 != 0:
		return -1
	if a == b:
		return 1
	return 2
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(solve(a, b))


import sys
input = sys.stdin.readline
a = int(input())
b = 0
while b < a:
	c = input().split(' ')
	d = int(c[0])
	e = int(c[1])
	f = (d + e) / 2
	g = 0
	if f.is_integer() == False:
		print(-1)
	if f.is_integer() == True:
		if d == 0 and e == 0:
			print(0)
			g = 1
		if d == e and g == 0:
			print(1)
			g = 1
		if g == 0:
			print(2)
	b = b + 1


from sys import *
import math
input = stdin.readline
I = int
R = range

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

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

def sJoin(a, sep):
	return '{}'.format(sep).join(a)

def arrJoin(a, sep):
	return '{}'.format(sep).join(map(str, a))

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

def main():
	for _ in R(I(input())):
		(c, d) = lineInput()
		add = c + d
		if c == d and c == 0:
			print(0)
		elif c == d:
			print(1)
		elif add % 2 == 0:
			print(2)
		else:
			print(-1)
main()


import sys
import io, os
import math
from heapq import *
gcd = math.gcd
sqrt = math.sqrt
floor = math.floor

def ceil(a, b):
	a = -a
	k = a // b
	k = -k
	return k
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def strinp(testcases):
	k = 5
	if testcases == -1 or testcases == 1:
		k = 1
	f = str(input())
	f = f[2:len(f) - k]
	return f

def main():
	t = int(input())
	for _ in range(t):
		arr = list(map(int, input().split()))
		c = arr[0]
		d = arr[1]
		if c == d:
			if c == 0:
				print(0)
			else:
				print(1)
			continue
		if (c + d) % 2 != 0:
			print(-1)
		else:
			print(2)
main()


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

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

def getliststr():
	return list(stdin.readline().split())

def getint():
	return int(stdin.readline().strip())

def getstr():
	return stdin.readline().strip()

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

def prlist(l):
	stdout.write(' '.join(list(map(str, l))) + '\n')
from sys import stdin, stdout
for _ in range(getint()):
	(c, d) = getmapint()
	(a, b) = (0, 0)
	if c == 0 and d == 0:
		pr(0)
		continue
	if c == d:
		pr(1)
		continue
	if abs(c - d) % 2 != 0:
		pr(-1)
		continue
	pr(2)


t = int(input())
ms = []
ms = [0] * t
for i in range(t):
	(c, d) = map(int, input().split())
	cnt = (c + d) // 2
	if abs(c - cnt) == abs(d - cnt):
		ms[i] = 2
	if c == d:
		ms[i] = 1
	if c == 0 and d == 0:
		ms[i] = 0
	if abs(c - cnt) != abs(d - cnt):
		ms[i] = -1
for i in range(t):
	print(ms[i])


n = int(input())
lst = []
ast = []
for i in range(0, n):
	p = input()
	lst.append(p)
for j in range(0, len(lst)):
	k = lst[j].split(' ')
	for l in range(0, 2):
		m = int(k[l])
		ast.append(m)
for i in range(0, len(ast), 2):
	if ast[i] == 0 and ast[i + 1] == 0:
		print('0')
	elif ast[i] != ast[i + 1] and (ast[i] - ast[i + 1]) % 2 == 0:
		print('2')
	elif ast[i] == ast[i + 1]:
		print('1')
	else:
		print('-1')


import sys
inp = sys.stdin.readline
for _ in range(int(inp())):
	(c, d) = map(int, inp().split())
	if (c + d) % 2 == 1:
		print(-1)
	elif c == d == 0:
		print(0)
	elif abs(c) == abs(d):
		print(1)
	else:
		print(2)


def solve(Test_cases):
	Resultant_list = []
	for i in range(Test_cases):
		string = input()
		(c, d) = string.split()
		diff = abs(int(c) - int(d))
		if int(c) == 0 and int(d) == 0:
			Resultant_list.append(0)
		elif diff % 2 == 1:
			Resultant_list.append(-1)
		elif diff == 0:
			Resultant_list.append(1)
		else:
			Resultant_list.append(2)
	return Resultant_list
Test_cases = int(input())
Result = solve(Test_cases)
for i in Result:
	print(i)


import os, sys
input = lambda : sys.stdin.buffer.readline().rstrip(b'\r\n')

def dbp(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)
a_str = lambda : input().decode('ascii')
get_int_list = lambda : [int(x) for x in input().split()]
join_str = lambda l, ch=' ': ch.join((str(x) for x in l))

def do_thing():
	(c, d) = get_int_list()
	if abs(c - d) % 2:
		return -1
	if c == d == 0:
		return 0
	if c == d:
		return 1
	return 2
maxcc = 1
maxcc = int(input())
for cc in range(maxcc):
	print(do_thing())


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations, accumulate, zip_longest, combinations_with_replacement
from math import gcd, floor, inf, log2, sqrt, log10, factorial
from bisect import bisect_right, bisect_left
from statistics import mode
from string import ascii_lowercase, ascii_uppercase
from heapq import heapify, heappop, heappush, heappushpop, heapreplace, nlargest, nsmallest, merge
from copy import deepcopy
cases = int(input())
for _ in range(cases):
	(a, b) = map(int, input().split())
	if a == b == 0:
		print(0)
	elif a == b:
		print(1)
	elif abs(a - b) % 2 == 1:
		print(-1)
	else:
		print(2)


import aifc
import os, sys
import math
from io import BytesIO, IOBase
from collections import Counter
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 sieve(n):
	p = [1 for i in range(n + 1)]
	z = 2
	while z * z <= n:
		if p[z] == 1:
			for i in range(z * z, n + 1, z):
				p[i] = 0
		z += 1
	primes = [2]
	for i in range(3, n + 1, 2):
		if p[i]:
			primes.append(i)
	return primes

def bins(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return leftGreater

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def decimalToBinary(N):
	B_Number = 0
	cnt = 0
	while N != 0:
		rem = N % 2
		c = pow(10, cnt)
		B_Number += rem * c
		N //= 2
		cnt += 1
	return B_Number

def binaryToDecimal(n):
	num = n
	dec_value = 0
	base1 = 1
	len1 = len(num)
	for i in range(len1 - 1, -1, -1):
		if num[i] == '1':
			dec_value += base1
		base1 = base1 * 2
	return dec_value

def binarySearch(arr, l, r, x):
	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 merge(arr, l, m, r):
	n1 = m - l + 1
	n2 = r - m
	L = [0] * n1
	R = [0] * n2
	for i in range(0, n1):
		L[i] = arr[l + i]
	for j in range(0, n2):
		R[j] = arr[m + 1 + j]
	i = 0
	j = 0
	k = l
	while i < n1 and j < n2:
		if L[i] <= R[j]:
			arr[k] = L[i]
			i += 1
		else:
			arr[k] = R[j]
			j += 1
		k += 1
	while i < n1:
		arr[k] = L[i]
		i += 1
		k += 1
	while j < n2:
		arr[k] = R[j]
		j += 1
		k += 1

def mergeSort(arr, l, r):
	if l < r:
		m = (l + (r - 1)) // 2
		mergeSort(arr, l, m)
		mergeSort(arr, m + 1, r)
		merge(arr, l, m, r)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	return gcd(b % a, a)
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x == y == 0:
		print(0)
	elif x == y:
		print(1)
	elif abs(x - y) == 1:
		print(-1)
	elif x == 0 or y == 0:
		if (x + y) % 2 != 0:
			print(-1)
		else:
			print(2)
	elif (x + y) % 2 == 0:
		print(2)
	else:
		print(-1)


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	(c, d) = map(int, stdin.readline().split(' '))
	if (c + d) % 2 == 0:
		if c == d:
			print(int(c != 0 or d != 0))
		else:
			print(2)
	else:
		print(-1)


ans = []
for _ in range(int(input())):
	(m, n) = input().split()
	a = int(m)
	b = int(n)
	if a == 0 and b == 0:
		ans.append(0)
	elif abs(a - b) == 0:
		ans.append(1)
	elif abs(a - b) % 2 == 0:
		ans.append(2)
	elif abs(a - b) != 0:
		ans.append(-1)
for e in ans:
	print(e)


a = int(input())
l = []
for i in range(a):
	l.append(input().split(' '))

def main(a, b):
	if a == b and a == 0:
		print(0)
	elif a == b and a != 0:
		print(1)
	elif a == -1 * b:
		print(1)
	elif (a - b) / 2 != (a - b) // 2:
		print(-1)
	else:
		print(2)
for i in l:
	main(int(i[0]), int(i[1]))


import sys
ints = (int(x) for x in sys.stdin.read().split())
sys.setrecursionlimit(3000)

def main():
	ntc = next(ints)
	for tc in range(1, ntc + 1):
		(c, d) = (next(ints) for i in range(2))
		ans = -1 if (d - c) % 2 else 2 if d != c else 0 if d == 0 == c else 1
		print(ans)
	return
main()


import sys
import math
import heapq
import itertools
from collections import deque, defaultdict
input = sys.stdin.readline

def solve(c, d):
	if abs(c - d) & 1 == 1:
		return -1
	if c == d and c == 0:
		return 0
	if c == d:
		return 1
	return 2
n = int(input())
for _ in range(n):
	(c, d) = map(int, input().split())
	print(solve(c, d))


def calc(a, b):
	if not a + b:
		return 0
	if (a - b) % 2:
		return -1
	if a == b:
		return 1
	return 2

def main():
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		print(calc(a, b))
main()


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

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

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

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(a, b) = value()
	if a == b:
		ans = int(a > 0)
	elif (a + b) % 2 == 0 and (a - b) % 2 == 0:
		ans = 2
	else:
		ans = -1
	print(ans)


n = int(input())
for i in range(n):
	t = list(input().split())
	a = int(t[0])
	b = int(t[1])
	if a == 0 and b == 0:
		print(0)
	elif a == b:
		print(1)
	elif abs(a - b) % 2 == 0:
		print(2)
	else:
		print(-1)


import sys
import os.path
from sys import stdin, stdout
from collections import *
from math import gcd, ceil, floor
mod = int(1000000000.0 + 7)
m1 = float('inf')
if os.path.exists('Updated prg/Input3d.txt'):
	sys.stdout = open('Updated prg/Output3d.txt', 'w')
	sys.stdin = open('Updated prg/Input3d.txt', 'r')

def sinp():
	return input()

def ninp():
	return int(sinp())

def mapinp():
	return map(int, sinp().split())

def smapinp():
	return map(str, sinp().split())

def linp():
	return list(mapinp())

def sl():
	return list(sinp().split())

def power(n):
	return 1 << n

def prnt(a):
	print(a)

def prntl(a):
	print(a, end=' ')

def prntlist(l1):
	print(*l1)
for _ in range(ninp()):
	(c, d) = mapinp()
	if c == 0 and d == 0:
		prnt(0)
	elif c == d:
		prnt(1)
	else:
		val = abs(c - d)
		if val % 2 == 1:
			prnt(-1)
		else:
			prnt(2)


t = int(input())
for iii in range(t):
	(a, b) = map(int, input().split())
	if a == b and a == 0:
		print(0)
	elif a == b:
		print(1)
	elif abs(a - b) % 2 == 0:
		print(2)
	else:
		print(-1)


import sys
for i in range(int(sys.stdin.readline())):
	(c, d) = map(int, sys.stdin.readline().split())
	if abs(c - d) % 2 == 1:
		print(-1)
		continue
	if c + d == 0:
		print(0)
		continue
	if c == d:
		print(1)
		continue
	print(2)


t = int(input())
for i in range(t):
	(c, d) = input().split()
	(c, d) = (int(c), int(d))
	n1 = (c + d) % 2
	n2 = (c + d) // 2
	if c == 0 and d == 0:
		print(0)
	elif n1 == 0:
		if n2 == c and n2 == d:
			print(1)
		else:
			print(2)
	else:
		print(-1)


t = int(input())
a = []
b = []
for i in range(t):
	it = input().split(' ')
	a.append(int(it[0]))
	b.append(int(it[1]))
for i in range(t):
	if abs(a[i] - b[i]) % 2 == 1 or (a[i] < 0 and b[i] < 0) or (a[i] < 0 and b[i] == 0 or (a[i] == 0 and b[i] < 0)):
		print('-1')
	elif a[i] == 0 and b[i] == 0:
		print('0')
	elif a[i] == b[i]:
		print('1')
	else:
		print(2)


from collections import defaultdict, Counter, deque
from math import sqrt, log10, log, floor, factorial, gcd
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations
from functools import lru_cache
import sys, io, os
input = sys.stdin.readline
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
inf = float('inf')
mod = 10 ** 9 + 7

def yn(a):
	print('YES' if a else 'NO')
ceil = lambda a, b: (a + b - 1) // b
t = int(input())
for i in range(t):
	(c, d) = [int(i) for i in input().split()]
	if c == d == 0:
		print(0)
	elif c == d:
		print(1)
	elif (c - d) % 2 == 0:
		print(2)
	else:
		print(-1)


mod = 1000000007
from sys import stdin, stdout
from collections import defaultdict, Counter, deque
for _ in range(int(stdin.readline())):
	(c, d) = map(int, stdin.readline().split())
	if c == d:
		if c == 0:
			print(0)
		else:
			print(1)
	elif abs(c - d) % 2 == 1:
		print(-1)
	else:
		print(2)


from collections import defaultdict
for _ in range(int(input())):
	(c, d) = map(int, input().split())
	(a, b) = (0, 0)
	if c == 0 and d == 0:
		print(0)
		continue
	if abs(c - d) % 2 == 1:
		print(-1)
		continue
	if c == d:
		print(1)
		continue
	else:
		print(2)


t = int(input())
z = []
r = 0
for q in range(0, t):
	[a, b] = input().split()
	a = int(a)
	b = int(b)
	z.append([a, b])
for (a, b) in z:
	if (a - b if a > b else b > a) % 2 != 0:
		r = -1
	if a == b != 0:
		r = 1
	if a != b and (a + b) % 2 == 0:
		r = 2
	if a == 0 and b == 0:
		r = 0
	print(r)


t = int(input())
while t > 0:
	t = t - 1
	(a, b) = map(int, input().split())
	if a == b:
		if a > 0:
			print(1)
		else:
			print(0)
	elif (a - b) % 2 != 0:
		print(-1)
	else:
		print(2)


import sys
from math import sqrt, ceil, floor, gcd
from collections import Counter
input = lambda : sys.stdin.readline()

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

def str_arr():
	return list(map(str, input().split()))

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

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

def get_flo():
	return map(float, input().split())

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

def solve(c, d):
	if abs(c - d) % 2 != 0:
		print(-1)
	elif c == d and c == 0:
		print(0)
	elif c == d:
		print(1)
	elif c == 0 or d == 0:
		print(2)
	else:
		print(2)
for _ in range(int(input())):
	(c, d) = get_int()
	solve(c, d)


from collections import deque
import math
test_cases = int(input())
for test_case in range(test_cases):
	(c, d) = list(map(int, input().split()))
	if c == d and c != 0:
		print(1)
	elif c == d and c == 0:
		print(0)
	elif (c + d) % 2 == 0:
		print(2)
	else:
		print(-1)


from sys import stdin
from collections import defaultdict
from bisect import insort, bisect_left
for _ in range(int(stdin.readline())):
	(m, n) = map(int, stdin.readline().split())
	if m == n:
		if m == 0:
			print(0)
		else:
			print(1)
	elif abs(m - n) % 2 == 0:
		print(2)
	else:
		print(-1)


t = int(input())

def check(c, d):
	if (c == d) & (c != 0):
		return 1
	elif (c == d) & (c == 0):
		return 0
	elif (c % 2 == 0) & (d % 2 == 0):
		return 2
	elif (c % 2 != 0) & (d % 2 != 0):
		return 2
	else:
		return -1
for i in range(t):
	[c, d] = list(map(int, input().split(' ')))
	print(check(c, d))


import sys
import io, os
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(c, d) = map(int, input().split())
	if c > d:
		(c, d) = (d, c)
	if c == 0 and d == 0:
		print(0)
		continue
	if c == d:
		print(1)
		continue
	if c % 2 != d % 2:
		print(-1)
	else:
		print(2)


t = int(input())
lan = []
for _ in range(t):
	(c, d) = map(int, input().split())
	if c == 0 and d == 0:
		lan.append(0)
	elif c == d:
		lan.append(1)
	elif (c + d) % 2 != 0:
		lan.append(-1)
	elif c == 0 and d == 0:
		lan.append(0)
	else:
		lan.append(2)
print(*lan, sep='\n')


import sys

def main():
	input = sys.stdin.readline
	print = sys.stdout.write
	t = int(input())
	for i1 in [0] * t:
		(n, x) = map(int, input().split())
		if n == x:
			if n == 0:
				print('0' + '\n')
			else:
				print('1' + '\n')
		elif abs(n - x) % 2 == 1:
			print('-1' + '\n')
		else:
			print('2' + '\n')
main()


t = int(input())
for _ in range(t):
	(c, d) = map(int, input().split())
	diff = abs(c - d)
	result = -1
	if diff % 2 == 1:
		print(result)
	elif diff == 0 and c != 0 and (d != 0):
		result = 0
		print(1)
	elif c == 0 and d == 0 and (diff == 0):
		print(0)
	elif diff % 2 == 0:
		print(2)


import math
import sys
import itertools
import fractions
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
for t in wtf[1:]:
	(c, d) = map(int, t.split())
	k = c + d
	if k % 2 != 0:
		print(-1)
		continue
	if c == 0 and d == 0:
		print(0)
	elif c == d:
		print(1)
	else:
		print(2)


from collections import Counter, deque
from math import *
mod = 1000000007

def solve():
	(a, b) = map(int, input().split())
	if abs(a - b) % 2 != 0:
		print(-1)
		return
	if a == b == 0:
		print(0)
		return
	if a == b:
		print(1)
		return
	print(2)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
q = []
for _ in range(t):
	q.append(list(map(int, input().split())))
for qu in q:
	(a, b) = qu
	if a == b:
		if a == 0:
			print(0)
		else:
			print(1)
	elif abs(a - b) % 2 == 1:
		print(-1)
	else:
		print(2)


def solve(c, d):
	if c == 0 and d == 0:
		return 0
	if c == d:
		return 1
	if (c - d) % 2 == 0:
		return 2
	return -1
n = int(input())
for k in range(n):
	(c, d) = map(int, input().split())
	ans = solve(c, d)
	print(ans)


import sys

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

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

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

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

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

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

def get_print(x):
	sys.stdout.write(x + '\n')

def get_print_int_same(x):
	sys.stdout.write(str(x) + ' ')

def get_print_same(x):
	sys.stdout.write(x + ' ')
from sys import maxsize

def solve():
	for _ in range(get_int()):
		(a, b) = get_ints()
		if a == 0 and b == 0:
			get_print_int(0)
		else:
			if a <= b:
				other = b - a
			else:
				other = a - b
			if other % 2 == 1:
				get_print_int(-1)
			elif other == 0:
				get_print_int(1)
			else:
				get_print_int(2)
solve()


tst = int(input())
tst_case = []
x = 0
outpt = []
for t in range(tst):
	tst_case.append(input().split())
	while x < len(tst_case):
		a = int(tst_case[x][0])
		b = int(tst_case[x][1])
		if a == b and a != 0:
			outpt.append(1)
		elif a == 0 and b == 0:
			outpt.append(0)
		elif ((a + b) / 2).is_integer():
			outpt.append(2)
		else:
			outpt.append(-1)
		x += 1
print(*outpt, sep='\n')


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


for i in range(int(input())):
	(c, d) = map(int, input().split())
	if c == d == 0:
		print(0)
	elif c == d:
		print(1)
	elif (max(c, d) - min(c, d)) % 2 == 1:
		print(-1)
	else:
		print(2)


try:
	for i in range(int(input())):
		(c, d) = map(int, input().split())
		if c == 0 and d == 0:
			print(0)
		elif c == d:
			print(1)
		elif abs(c - d) % 2 == 0:
			print(2)
		else:
			print(-1)
except Exception as e:
	pass


from sys import stdin

def A():
	t = int(stdin.readline())
	while t:
		t -= 1
		(c, d) = [int(x) for x in stdin.readline().split()]
		if abs(c - d) % 2 == 1:
			print(-1)
		elif c == 0 and d == 0:
			print(0)
		elif c == d:
			print(1)
		else:
			print(2)
A()


n_t = int(input())
List_result = []
for i in range(n_t):
	(c, d) = map(int, input().split(' '))
	if (c + d) % 2 == 0:
		if c != d:
			List_result.append(2)
		elif c == d and c == 0:
			List_result.append(0)
		else:
			List_result.append(1)
	else:
		List_result.append(-1)
for i in List_result:
	print(i)


m = int(input())
l = []
for i in range(m):
	(a, b) = map(int, input().split())
	if abs(a - b) % 2 != 0:
		l.append(-1)
	elif a == 0 and b == 0:
		l.append(0)
	elif a != b:
		l.append(2)
	else:
		l.append(1)
for i in l:
	print(i)


import sys

def rl():
	return sys.stdin.readline().strip()
num_cases = int(rl())
for _ in range(num_cases):
	(a, b) = map(int, rl().split())
	if a == 0 and b == 0:
		print(0)
	elif a == b:
		print(1)
	elif (a - b) % 2 == 0:
		print(2)
	else:
		print(-1)


from collections import deque
import heapq
from math import sqrt
import operator
from operator import itemgetter
import sys
import copy
inf_var = 0
if inf_var == 1:
	inf = open('input.txt', 'r')
else:
	inf = sys.stdin
input = inf.readline

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

def read_one_float():
	return float(input().rstrip('\n'))

def read_list_of_ints():
	res = [int(val) for val in input().rstrip('\n').split(' ')]
	return res

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

def main():
	tests = read_one_int()
	for _ in range(tests):
		(c, d) = read_list_of_ints()
		(a, b) = (0, 0)
		if c + d == 0:
			print(0)
			continue
		if c == d:
			print(1)
			continue
		if abs(c - d) % 2:
			print(-1)
			continue
		print(2)
main()