There is an infinite 2-dimensional grid. The robot stands in cell $(0, 0)$ and wants to reach cell $(x, y)$. Here is a list of possible commands the robot can execute:

move north from cell $(i, j)$ to $(i, j + 1)$;

move east from cell $(i, j)$ to $(i + 1, j)$;

move south from cell $(i, j)$ to $(i, j - 1)$;

move west from cell $(i, j)$ to $(i - 1, j)$;

stay in cell $(i, j)$.

The robot wants to reach cell $(x, y)$ in as few commands as possible. However, he can't execute the same command two or more times in a row.

What is the minimum number of commands required to reach $(x, y)$ from $(0, 0)$?


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of testcases.

Each of the next $t$ lines contains two integers $x$ and $y$ ($0 \le x, y \le 10^4$) — the destination coordinates of the robot.


-----Output-----

For each testcase print a single integer — the minimum number of commands required for the robot to reach $(x, y)$ from $(0, 0)$ if no command is allowed to be executed two or more times in a row.


-----Examples-----

Input
5
5 5
3 4
7 1
0 0
2 0
Output
10
7
13
0
3


-----Note-----

The explanations for the example test:

We use characters N, E, S, W and 0 to denote going north, going east, going south, going west and staying in the current cell, respectively.

In the first test case, the robot can use the following sequence: NENENENENE.

In the second test case, the robot can use the following sequence: NENENEN.

In the third test case, the robot can use the following sequence: ESENENE0ENESE.

In the fourth test case, the robot doesn't need to go anywhere at all.

In the fifth test case, the robot can use the following sequence: E0E.

Source: codeforces | Difficulty: EASY
Tags: Mathematics


Solutions:
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split(' '))
	if a == b:
		print(2 * a)
	else:
		print(a + b + abs(a - b) - 1)


import math
t = int(input())
while t > 0:
	t -= 1
	(x, y) = map(int, input().split())
	ans = 0
	ans = max(x, y) * 2 - 1
	if x == y:
		ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	(x, y) = [int(s) for s in input().split()]
	lastMove = ''
	moveCount = 0
	actualX = 0
	actualY = 0
	firstMove = 'x' if x > y else 'y'
	while actualX != x or actualY != y:
		if firstMove == 'y':
			if actualX < x and lastMove == 'right' and (actualY == y) or (actualY < y and lastMove == 'up' and (actualX == x)):
				lastMove = 'none'
				moveCount += 1
			elif actualY < y and lastMove != 'up' or (actualX < x and lastMove == 'right'):
				lastMove = 'up'
				actualY += 1
				moveCount += 1
			elif actualX < x and lastMove != 'right' or (actualY < y and lastMove == 'up'):
				lastMove = 'right'
				actualX += 1
				moveCount += 1
		elif actualX < x and lastMove == 'right' and (actualY == y) or (actualY < y and lastMove == 'up' and (actualX == x)):
			lastMove = 'none'
			moveCount += 1
		elif actualX < x and lastMove != 'right' or (actualY < y and lastMove == 'up'):
			lastMove = 'right'
			actualX += 1
			moveCount += 1
		elif actualY < y and lastMove != 'up' or (actualX < x and lastMove == 'right'):
			lastMove = 'up'
			actualY += 1
			moveCount += 1
	print(moveCount)


def move(a):
	(n, m) = map(int, input().split())
	if n == m:
		return 2 * m
	else:
		return max(n, m) * 2 - 1
t = int(input())
while t > 0:
	print(move(t))
	t -= 1


from sys import stdin
nii = lambda : map(int, stdin.readline().split())
lnii = lambda : list(map(int, stdin.readline().split()))
t = int(input())
for tt in range(t):
	(x, y) = nii()
	ans = x + y
	maxv = max(x, y)
	minv = min(x, y)
	diff = maxv - minv
	if diff > 0:
		ans += diff - 1
	print(ans)


a = int(input())
for q in range(a):
	b = [int(i) for i in input().split()]
	if b[0] == b[1]:
		print(2 * b[0])
	else:
		print(max(b) * 2 - 1)


t = int(input())
for x in range(t):
	c = 0
	(a, b) = map(int, input().split())
	d = abs(a - b)
	if d >= 2:
		c = abs(a + b + d - 1)
	else:
		c = abs(a + b)
	print(c)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if n == m:
		print(2 * n)
	else:
		print(2 * max(n, m) - 1)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if x == y:
		print(x + y)
	else:
		z = min(x, y)
		m = z * 2 + (abs(x - y) * 2 - 1)
		print(m)


t = int(input())
for T in range(t):
	(xf, yf) = list(map(int, input().split()))
	c = 0
	(x, y) = (0, 0)
	while x != xf or y != yf:
		if c == 0 and xf > yf:
			if xf - x > 0:
				x += 1
			elif xf - x < 0:
				x -= 1
			c += 1
		if x == xf and y == yf:
			break
		if yf - y > 0:
			y += 1
		elif yf - y < 0:
			y -= 1
		c += 1
		if x == xf and y == yf:
			break
		if xf - x > 0:
			x += 1
		elif xf - x < 0:
			x -= 1
		c += 1
	print(c)


from math import *
for something in range(int(input())):
	(x, y) = map(int, input().split())
	if abs(x - y) > 1:
		print(2 * max(x, y) - 1)
	else:
		print(x + y)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(x, y) = list(map(int, stdin.readline().split()))
	if x < y:
		(x, y) = (y, x)
	if x == y:
		print(x + y)
		continue
	gaps = x - 1
	unfilled = gaps - y
	ans = unfilled
	print(x + y + ans)


t = int(input())
for z in range(t):
	(x, y) = input().split()
	(x, y) = (int(x), int(y))
	if x == y:
		print(2 * x)
	elif x > y:
		print(2 * x - 1)
	elif x < y:
		print(2 * y - 1)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a != b:
		k = 1
	else:
		k = 0
	print(max(a, b) * 2 - k)


t = int(input())
for i in range(t):
	(x, y) = list(map(int, input().split()))
	if x == y:
		print(x * 2)
		continue
	else:
		print(max(x, y) * 2 - 1)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(x, y) = list(map(int, input().split()))
		if abs(x - y) == 0:
			yield (x * 2)
		else:
			yield (abs(x - y) * 2 - 1 + min(x, y) * 2)
t = int(input())
ans = gift()
print(*ans, sep='\n')


try:
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		ans = 0
		if a == b:
			ans = a + b
		else:
			ans = a + b + (abs(a - b) - 1)
		print(ans)
except EOFError as e:
	pass


from sys import stdout, stdin
from collections import defaultdict, deque
t = int(stdin.readline())
for _ in range(t):
	(n, m) = map(int, stdin.readline().split())
	if n == m:
		print(n + m)
	else:
		print(2 * max(n, m) - 1)


t = int(input())
for i in range(t):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	if x == y:
		print(2 * x)
	else:
		print(2 * max(x, y) - 1)


test_cases = int(input())
for i in range(test_cases):
	(x, y) = map(int, input().split())
	ans = max(x, y) * 2 - 1
	if x == y:
		ans += 1
	print(ans)


t = int(input())
for x in range(t):
	(x, y) = map(int, input().split())
	if x >= 0 and y <= 10000:
		if x == y:
			print(x + y)
		else:
			print(x + y + (abs(x - y) - 1))


t = int(input())
for i in range(0, t):
	(a, b) = map(int, input().split(' '))
	print(min(a, b) * 2 + max(a, b) - min(a, b) + max(0, max(a, b) - min(a, b) - 1))


i = int(input())
while i:
	i -= 1
	(x, y) = map(int, input().split())
	if x == y:
		print(x + y)
	elif x > y:
		print(2 * x - 1)
	elif y > x:
		print(2 * y - 1)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
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 main():
	t = int(input())
	for i in range(t):
		(x, y) = map(int, input().split())
		if x == y:
			print(x + y)
		else:
			print(2 * max(x, y) - 1)
main()


t = int(input())
for _ in range(t):
	(x, y) = [abs(s) for s in list(map(int, input().split()))]
	moves = 2 * min(x, y) + max(0, 2 * (max(x, y) - min(x, y)) - 1)
	print(moves)


T = int(input())
for i in range(T):
	(X, Y) = map(int, input().split())
	diff = abs(Y - X)
	ans = (max(X, Y) - diff) * 2
	if diff > 0:
		ans += diff + (diff - 1)
	print(ans)


t = int(input())
for test in range(t):
	(a, b) = (int(i) for i in input().split())
	if a > b:
		(a, b) = (b, a)
	if a != b:
		k = a + b + (b - a - 1)
	else:
		k = a + b
	print(k)


t = int(input())
while t:
	(x, y) = map(int, input().split())
	if x == y:
		print(x + y)
	else:
		print(2 * min(x, y) + 1 + 2 * (max(x, y) - min(x, y) - 1))
	t -= 1


t = int(input())
l = []
for i in range(t):
	(a, b) = map(int, input().split())
	s = 0
	max_ = max(a, b)
	min_ = min(a, b)
	s += min_ * 2
	if max_ - min_ == 0:
		l.append(s)
	else:
		l.append(s + (max_ - min_) * 2 - 1)
for i in l:
	print(i)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	if x == y:
		print(2 * x)
	else:
		print(2 * max(x, y) - 1)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if abs(x - y) <= 1:
		print(x + y)
	else:
		print(3 + (max(x, y) - 2) * 2)


t = int(input())
for i in range(t):
	s = 0
	(x, y) = map(int, input().strip().split())
	if x > y:
		s = 2 * x - 1
	elif x == y:
		s = 2 * x
	else:
		s = 2 * y - 1
	print(s)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		print(a + b)
	elif max(a, b) - min(a, b) > 1:
		print(max(a, b) + min(a, b) + (max(a, b) - min(a, b) - 1))
	else:
		print(a + b)


t = int(input())
for _ in range(t):
	arr = list(map(int, input().split()))
	res = 0
	if arr[0] != 0 and arr[1] != 0:
		if arr[0] == arr[1]:
			res += min(arr) * 2
		else:
			res += min(arr) * 2 + (abs(arr[0] - arr[1]) * 2 - 1)
	elif arr[0] == 0 and arr[1] == 0:
		res = 0
	else:
		res += max(arr) * 2 - 1
	print(res)


from sys import stdin, stdout
from collections import *
from math import gcd, ceil, floor
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')
for _ in range(int(input())):
	(m, n) = mp()
	if abs(m - n) <= 1:
		print(m + n)
	elif m > n:
		print(2 * m - 1)
	else:
		print(2 * n - 1)


t = int(input())
pos = list()
for j in range(t):
	pos.append(list(map(int, input().split())))
for j in range(t):
	if pos[j][0] == pos[j][1]:
		print(2 * pos[j][0])
	else:
		print(2 * max(pos[j]) - 1)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == 0 and b == 0:
		print('0')
	elif a == 0 or b == 0:
		print(2 * max(a, b) - 1)
	elif abs(a - b) <= 1:
		print(a + b)
	else:
		print(2 * max(a, b) - 1)


a = input()
for x in range(int(a)):
	b = input().split(' ')
	tag = int(b[0])
	tag1 = int(b[1])
	if max(tag, tag1) - min(tag, tag1) <= 1:
		print(tag + tag1)
	else:
		print(min(tag, tag1) * 2 + (max(tag, tag1) - min(tag, tag1) - 1) * 2 + 1)


def solve(lst):
	if lst[0] == lst[1]:
		print(lst[0] + lst[1])
	else:
		print(lst[0] + lst[1] + (abs(lst[0] - lst[1]) - 1))
num_iter = int(input())
while num_iter != 0:
	lst = list(map(int, input().split()))
	solve(lst)
	num_iter -= 1


t = int(input())
for i in range(0, t):
	(x, y) = input().split(' ')
	x = int(x)
	y = int(y)
	cnt = 0
	if x <= y:
		cnt = x
	else:
		cnt = y
	x -= cnt
	y -= cnt
	cnt *= 2
	if x == 0:
		if 2 * y - 1 > 0:
			cnt += 2 * y - 1
	elif 2 * x - 1 > 0:
		cnt += 2 * x - 1
	print(cnt)


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	if abs(a - b) <= 1:
		print(a + b)
	else:
		print(a + b + abs(a - b) - 1)


n = int(input())
ans = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if x < y:
		ans = 2 * y
	else:
		ans = 2 * x
	if x == y:
		print(ans)
	else:
		print(ans - 1)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	s = 2 * (min(x, y) + abs(x - y)) - 1 if x != y else x + y
	print(s)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	ans = abs(x) + abs(y) + max(0, abs(x - y) - 1)
	print(ans)


from sys import stdin, stdout
import math, bisect
from collections import Counter, deque, defaultdict
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
S = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()

def pr(a):
	print(' '.join(list(map(str, a))))

def solve():
	(x, y) = M()
	if abs(x - y) <= 1:
		print(x + y)
	else:
		print(x + y - 1 + max(x, y) - min(x, y))
for _ in range(I()):
	solve()


t = int(input())
for i in range(1, t + 1):
	(x, y) = map(int, input().split())
	if x == y:
		print(x + y)
	elif x > y:
		print(2 * x - 1)
	elif y > x:
		print(2 * y - 1)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	if n == m:
		print(n + m)
	else:
		sum = 0
		sum = 2 * min(n, m)
		x = max(n, m) - min(n, m)
		sum += 2 * x - 1
		print(sum)


import math
n = int(input())
for i in range(n):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	if x == y:
		steps = x * 2
	else:
		steps = max(x, y) * 2 - 1
	print(steps)


for _ in range(int(input())):
	(p, q) = map(int, input().split())
	if p == q:
		print(2 * p)
	elif p > q:
		print(2 * p - 1)
	else:
		print(2 * q - 1)


import os
import sys
from io import BytesIO, IOBase

def solution():
	(x, y) = map(int, input().split())
	val = abs(x - y)
	val2 = min(x, y)
	print(2 * val2 + max(2 * val - 1, 0))
	return

def main():
	testcases = 1
	testcases = int(input())
	for _ in range(testcases):
		solution()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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


t = int(input())
for a in range(t):
	(i, j) = map(int, input().split())
	if i == 0 and j == 0:
		print(0)
	elif i == j:
		print(i + j)
	elif i > j:
		print(2 * i - 1)
	else:
		print(2 * j - 1)


t = int(input())
for f in range(t):
	x = input().split(' ')
	if x[0] == x[1]:
		print(int(x[0]) * 2)
	elif int(x[0]) > int(x[1]):
		print(int(x[1]) * 2 + 1 + (int(x[0]) - int(x[1]) - 1) * 2)
	else:
		print(int(x[0]) * 2 + 1 + (int(x[1]) - int(x[0]) - 1) * 2)


repeat = int(input())
for rep in range(repeat):
	(a, b) = map(int, input().split())
	x = max(abs(a), abs(b))
	y = min(abs(a), abs(b))
	i = 0
	string_direction = ''
	while not (x == 0 and y == 0):
		x -= 1
		i += 1
		if x == 0 and y == 0:
			break
		if y != 0:
			y -= 1
			i += 1
		else:
			i += 1
	print(i)


a = int(input())
for i in range(a):
	b = [int(x) for x in input().split()]
	b.sort()
	c = b[1] - b[0]
	if c == 0:
		ans = 2 * b[0]
	else:
		ans = 2 * b[0] + 2 * c - 1
	print(ans)


def solve():
	(x, y) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	diff = y - x
	if diff > 0:
		print(x * 2 + diff * 2 - 1)
	else:
		print(x * 2)
for _ in range(int(input())):
	solve()


for Pythonic__Python in range(int(input())):
	(x, y) = map(int, input().split())
	print(2 * max(x, y) - 1) if x != y else print(x + y)


n = int(input())
tests = []
ans = []
for i in range(n):
	tests.append(list(map(int, input().split())))
for (x, y) in tests:
	pd = abs(x - y)
	if pd <= 1:
		ans.append(x + y)
	else:
		ans.append(x + y + pd - 1)
for j in ans:
	print(j)


def count_steps(x, y):
	if x == y:
		return 2 * x
	if x > y:
		return 2 * y + 2 * (x - y) - 1
	if y > x:
		return 2 * x + 2 * (y - x) - 1

def main():
	t = int(input())
	for _ in range(t):
		(x, y) = map(int, input().split())
		print(count_steps(x, y))
main()


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

def solve():
	for _ in range(int(input())):
		(x, y) = li()
		(y, x) = (max(x, y), min(x, y))
		m = x + y
		m += (y - x - 1) * (y - x - 1 > 0)
		print(m)
solve()


for i in range(int(input())):
	(x, y) = map(int, input().split())
	p = 0
	p += min(x, y) * 2
	if abs(x - y) > 0:
		p += abs(x - y) * 2
		p -= 1
	print(p)


def main():
	T = int(input())
	for t in range(T):
		(x, y) = map(int, input().strip().split(' '))
		steps = 2 * min(x, y)
		add = max(x, y) - min(x, y)
		if add == 0:
			print(steps)
			continue
		if add % 2 == 0:
			steps += 2 * (add - 2) + 3
		else:
			steps += 2 * (add - 1) + 1
		print(steps)
main()


for u in range(int(input())):
	(a, b) = map(int, input().split())
	x = min(a, b)
	y = max(a, b)
	if x == y:
		print(x + y)
	else:
		print(2 * y - 1)


for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	(x, y) = (min(x, y), max(x, y))
	m = y - x
	if m > 0:
		m = m * 2 - 1
	print(x * 2 + m)


numb = int(input())
c = 0
for i in range(numb):
	c = 0
	line = input()
	arrr = line.split(' ')
	x = int(arrr[0])
	y = int(arrr[1])
	if -1 <= y - x <= 1:
		c = y + x
	elif x >= y:
		cc = y * 2 + 1
		bb = (abs(x - y) - 1) * 2
		c = cc + bb
	else:
		cc = x * 2 + 1
		bb = (abs(x - y) - 1) * 2
		c = cc + bb
	print(c)


numcases = int(input())
outputlist = []

def findsteps():
	ij = input().split()
	i = int(ij[0])
	j = int(ij[1])
	absi = abs(i)
	absj = abs(j)
	movecount = 0
	if absj == absi:
		movecount = absi + absj
		outputlist.append(movecount)
	else:
		if absi > absj:
			movecount = absi * 2 - 1
		elif absi < absj:
			movecount = absj * 2 - 1
		outputlist.append(movecount)
for i in range(numcases):
	findsteps()
for i in range(numcases):
	print(outputlist[i])


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	ans = min(x, y)
	x -= ans
	y -= ans
	ans *= 2
	if x > 0:
		ans += x + (x - 1)
	elif y > 0:
		ans += y + (y - 1)
	print(max(ans, 0))


for t in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	ans = 2 * min(x, y)
	if x != y:
		ans += 1 + 2 * (abs(x - y) - 1)
	print(ans)


for t in range(int(input())):
	(x, y) = map(int, input().split())
	if x == y:
		print(x + y)
	else:
		z = max(x, y)
		print(z + z - 1)


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	comm = max(x, y) * 2 - 1
	if x == y:
		comm += 1
	print(comm)


t = int(input())
a = []
for i in range(0, t):
	inp = list(map(int, input().split()))
	for j in range(0, 2):
		if inp[0] == inp[1]:
			ans = 2 * inp[0]
		else:
			bigger = max(inp[0], inp[1])
			ans = 2 * bigger - 1
	a.append(ans)
for i in range(0, t):
	print(a[i], '\r')


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()

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

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

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

def print_list(l):
	print(' '.join(map(str, l)))
from collections import deque as dq
for i in range(N()):
	(x, y) = RL()
	c = 0
	a = min(x, y)
	c += 2 * min(x, y)
	x -= a
	y -= a
	if x or y:
		c += 2 * x
		c += 2 * y
		c -= 1
	print(c)


n = int(input())
for i in range(n):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	if not abs(x - y) <= 1:
		print(x + y + (abs(x - y) - 1))
	else:
		print(x + y)


import sys
sys.setrecursionlimit(10 ** 5)
input = lambda : sys.stdin.readline().strip()
inp = lambda : list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	(x, y) = inp()
	if y > x:
		(x, y) = (y, x)
	ans = 2 * y + 1 if x != y else 2 * y
	x = x - y - 1 if x != y else x - y
	ans += 2 * x if x != 0 else 0
	print(ans)


import copy
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))

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

def exgcd(a, b):
	if not b:
		return (1, 0)
	(y, x) = exgcd(b, a % b)
	y -= a // b * x
	return (x, y)

def getinv(a, m):
	(x, y) = exgcd(a, m)
	return --1 if x == 1 else x % m

def comb(n, b):
	res = 1
	b = min(b, n - b)
	for i in range(b):
		res = res * (n - i) * getinv(i + 1, mo) % mo
	return res % mo

def quickpower(a, n):
	res = 1
	while n:
		if n & 1:
			res = res * a % mo
		n >>= 1
		a = a * a % mo
	return res
t = int(input())
for ti in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		print(a + b)
	else:
		print(max(a, b) * 2 - 1)


t = int(input())
x = 0
for I in range(t):
	(a, b) = map(int, input().split())
	if a < b:
		x = 2 * b
	else:
		x = 2 * a
	if a == b:
		print(x)
	else:
		print(x - 1)


t = int(input())
ans = 0
for i in range(t):
	(a, b) = map(int, input().split())
	if a < b:
		ans = 2 * b
	else:
		ans = 2 * a
	if a == b:
		print(ans)
	else:
		print(ans - 1)


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	print(2 * max(x, y) - (x != y))


def shortest(x, y):
	if x == y:
		return 2 * x
	return 2 * max(abs(x), abs(y)) - 1
n = int(input())
for i in range(n):
	s = input().split()
	print(shortest(int(s[0]), int(s[1])))


t = int(input())
l1 = []
while t != 0:
	s = input()
	l = s.split(' ')
	x = int(l[0])
	y = int(l[1])
	ans = max(x, y) * 2 - 1
	if x == y:
		ans += 1
	l1.append(ans)
	t -= 1
for i in l1:
	print(i)


t = int(input())
while t:
	(x, y) = map(int, input().split())
	ans = x + y
	c = abs(x - y)
	if c:
		ans += c - 1
	print(ans)
	t = t - 1


from math import *
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if n > m:
		(n, m) = (m, n)
	a1 = n * 2
	a2 = m - n
	if a2 == 0:
		print(a1)
	else:
		print(a1 + a2 + a2 - 1)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	(a, b) = (abs(a), abs(b))
	x = min(a, b)
	left = max(a, b) - x
	ans = 2 * min(a, b)
	if left == 0:
		print(ans)
	else:
		ans += 1
		left -= 1
		ans += 2 * left
		print(ans)


import sys
input = sys.stdin.readline
from collections import *
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(m, M) = (min(x, y), max(x, y))
	d = M - m
	ans = 2 * m
	if d > 0:
		ans += 2 * d - 1
	print(ans)


t = int(input())
num = 0
for i in range(t):
	(x, y) = map(int, input().split())
	if x < y:
		num = 2 * y
	else:
		num = 2 * x
	if x == y:
		print(num)
	else:
		print(num - 1)


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	print(2 * max(x, y) - (x != y))


from sys import stdin, stdout, stderr, maxsize
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
S = lambda : stdin.readline().replace('\n', '').strip()
stpr = lambda x: stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
from math import ceil, floor
from _collections import defaultdict
from bisect import bisect_left, bisect_right
for _ in range(I()):
	(x, y) = tup()
	if x == y:
		print(x + y)
	else:
		print(2 * max(x, y) - 1)


t = int(input())
for i in range(t):
	tmp = input().split(' ')
	x = int(tmp[0])
	y = int(tmp[1])
	mi = min(x, y)
	ma = max(x, y)
	print((ma - mi) * 2 - 1 + 2 * mi + (ma == mi))


t = int(input())
for test in range(t):
	(x, y) = [int(i) for i in input().split(' ')]
	if x == 0 and y == 0:
		print(0)
	else:
		a = min(x, y)
		b = max(x, y)
		if a == b:
			print(a + b)
		else:
			print(2 * b - 1)


def convert(lis):
	for i in range(len(lis)):
		lis[i] = int(lis[i])
	return lis
t = int(input())
for i in range(t):
	param = convert(input().split())
	if param[1] == param[0]:
		print(param[1] * 2)
	elif param[0] == 0 or param[1] == 0:
		if param[0] == param[1]:
			print('0')
		elif param[0] == 0:
			print(param[1] * 2 - 1)
		else:
			print(param[0] * 2 - 1)
	else:
		start = [0, 0]
		count = 0
		if param[1] > param[0]:
			maximum = param[1]
			minimum = param[0]
		else:
			maximum = param[0]
			minimum = param[1]
		count = minimum * 2
		start = [minimum, minimum]
		count += 2 * (maximum - minimum) - 1
		print(count)


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def solve():
	(x, y) = map(int, input().split())
	(x, y) = sorted([x, y])
	ans = 2 * x
	if y - x:
		ans += 2 * (y - x) - 1
	print(ans)
t = int(input())
for _ in range(t):
	solve()


import sys
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from math import *
abc = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(ii1()):
	(n, m) = iia()
	print(n + m + max(max(n, m) - min(n, m) - 1, 0))


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	if x == y:
		print(x + y)
	elif abs(x - y) == 1:
		print(x + y)
	else:
		m = max(x, y)
		print(m * 2 - 1)


t = int(input().strip())
while t > 0:
	t -= 1
	n = list(map(int, input().strip().split()))
	if n[0] == n[1]:
		ans = 2 * abs(n[0])
	elif n[0] == 0 or n[1] == 0:
		if n[0] == 0:
			ans = 2 * abs(n[1]) - 1
		else:
			ans = 2 * abs(n[0]) - 1
	else:
		(x, y) = (abs(n[0]), abs(n[1]))
		diff = abs(x - y)
		ans = 2 * min(x, y) + 2 * diff - 1
	print(ans)


n = int(input())
while n != 0:
	(x, y) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	res = x * 2
	if y - x > 0:
		res += 1
	res += (x + y - res) * 2
	print(res)
	n -= 1


count = int(input())
for i in range(count):
	(a, b) = [int(x) for x in input().split()]
	c = abs(a - b)
	if c == 0:
		print(2 * a)
	else:
		print(2 * min(a, b) + 2 * c - 1)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x == y:
		print(x + y)
	else:
		p = max(x, y)
		print(2 * p - 1)


n = int(input())
while n:
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if a < b:
		(a, b) = (b, a)
	temp = 0
	temp = a + b + max(0, a - b - 1)
	print(temp)
	n -= 1


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	if y < x:
		ans = y * 2 + (x - y) * 2 - 1
	elif x < y:
		ans = x * 2 + (y - x) * 2 - 1
	elif x == y:
		ans = x + y
	print(ans)
	t = t - 1


t = int(input())
while t:
	t = t - 1
	lis = list(map(int, input().split()))
	x = lis[0]
	y = lis[1]
	if x == y:
		print(2 * x)
	else:
		p = min(x, y)
		print(2 * (max(x, y) - p) - 1 + 2 * p)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if abs(x - y) <= 1:
		print(abs(x + y))
	else:
		print(abs(x + y) + max(x, y) - min(x, y) - 1)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x == y:
		print(x + y)
	else:
		print(x + y + abs(x - y) - 1)


import sys
input = sys.stdin.readline

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

def inara():
	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 _ in range(t):
	(x, y) = invr()
	ans = min(x, y)
	x -= ans
	y -= ans
	ans *= 2
	if x > 0 or y > 0:
		ans += 2 * max(x, y) - 1
	print(ans)


x = int(input())
while x:
	x -= 1
	(a, b) = map(int, input().split())
	if a == b:
		print(a + b)
	elif a > b:
		print(2 * a - 1)
	elif b > a:
		print(2 * b - 1)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	print(max(a, b) * 2 - (a != b))


for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	d = 2 * min(x, y)
	if x != y:
		d += 2 * abs(x - y) - 1
	print(d)


t = int(input())

def q(x, y):
	if x == y:
		return x + y
	else:
		return x + y + (abs(x - y) - 1)
for i in range(t):
	j = input().split()
	(x, y) = (int(j[0]), int(j[1]))
	print(q(x, y))


def get_primeFactor(n):
	res = [1]
	x = 2
	while x * x <= n:
		while n % x == 0:
			res.append(x)
			n //= x
		x += 1
	if n > 1:
		res.append(n)
	return res

def getFactor(n):
	res = {1}
	x = 2
	while x * x <= n:
		if n % x == 0:
			res.add(x)
			res.add(n // x)
		x += 1
	return res
for _ in range(int(input())):
	(x, y) = tuple(map(int, input().split()))
	ans = x + y
	if abs(x - y) > 1:
		ans += abs(x - y) - 1
	print(ans)


s = input()
while True:
	try:
		(a, b) = map(int, input().split(' '))
		if b > a:
			(a, b) = (b, a)
		print(a + b + max(0, a - b - 1))
	except:
		break


for _ in range(int(input())):
	(m, n) = list(map(int, input().split()))
	if m != n:
		print(2 * max(m, n) - 1)
	else:
		print(m + n)


for s in [*open(0)][1:]:
	(x, y) = map(int, s.split())
	print(2 * max(x, y) - (x != y))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	step = 0
	i = 0
	j = 0
	l = ['0']
	while i < x or j < y:
		if i < x and j < y:
			if l[len(l) - 1] == 'E':
				l.append('N')
				l.append('E')
				step += 2
				i += 1
				j += 1
			else:
				l.append('E')
				l.append('N')
				step += 2
				i += 1
				j += 1
		elif i < x:
			step += 2 * (x - i) - 1
			l.append('E0' * (x - i))
			i = x
		elif j < y:
			step += 2 * (y - j) - 1
			l.append('N0' * (y - j))
			j = y
	print(step)


t = int(input())
i = 0
j = 0
for a in range(t):
	(x, y) = [int(b) for b in input().split()]
	m = max(x, y)
	if x == y:
		print(2 * m)
	else:
		print(2 * m - 1)


t = int(input())
for i in range(t):
	robotpos = [0, 0]
	dest = input()
	destinationf = dest.split()
	destination = [0, 0]
	minim = 0
	if int(destinationf[0]) >= int(destinationf[1]):
		destination[0] = int(destinationf[0])
		destination[1] = int(destinationf[1])
		minim = int(destinationf[1])
	if int(destinationf[0]) < int(destinationf[1]):
		destination[0] = int(destinationf[1])
		destination[1] = int(destinationf[0])
		minim = int(destinationf[0])
	contador = minim * 2
	robotpos = [minim, minim]
	if robotpos != destination:
		contador = contador + 1 + 2 * (destination[0] - robotpos[0] - 1)
	print(contador)


for _ in range(0, int(input())):
	(x, y) = sorted(map(int, input().split()))
	print(x + y + max(0, y - x - 1))


t = int(input())
for i in range(t):
	(r, c) = list(map(int, input().split()))
	if r == c:
		print(r + c)
	else:
		print(r + c + abs(r - c) - 1)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x == y:
		print(x + y)
	elif x > y:
		print(x + x - 1)
	else:
		print(y + y - 1)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x == y:
		print(x + y)
	elif x < y:
		print(2 * y - 1)
	else:
		print(2 * x - 1)


n = int(input())
for i in range(n):
	(x, y) = [int(xx) for xx in input().split()]
	if x == y:
		print(x + y)
	else:
		maxx = max(x, y)
		print(2 * maxx - 1)


for __ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	ans = min(abs(a), abs(b)) * 2
	ans += max(0, (max(abs(a), abs(b)) - min(abs(a), abs(b)) - 1) * 2 + 1)
	print(ans)


for x in range(int(input())):
	(h, m) = list(map(int, input().split()))
	(h, m) = (max(h, m), min(h, m))
	if h - m > 0:
		print(m * 2 + max(0, (h - m - 1) * 2) + 1)
	else:
		print(m * 2)


for (x, y) in [[*map(int, input().split())] for _ in ' ' * int(input())]:
	(y, x) = (min(abs(x), abs(y)), max(abs(x), abs(y)))
	x = x - y
	print(2 * y + min(4 * (x // 2) + x % 2, 2 * x - [0, 1][x != 0]))


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(i, j) = map(int, input().split())
	if i == j:
		print(2 * i)
	else:
		print(2 * max(i, j) - 1)


t = int(input())
result = []
for i in range(0, t):
	(x, y) = [int(s) for s in input().split()]
	if x == y:
		end = 2 * x
	elif x > y:
		end = 2 * x - 1
	elif y > x:
		end = 2 * y - 1
	result.append(str(end))
print('\n'.join(result))


s = int(input())
for x in range(s):
	c = 0
	(a, b) = map(int, input().split())
	f = abs(a - b)
	if f >= 2:
		c = abs(a + b + f - 1)
	else:
		c = abs(a + b)
	print(c)


t = int(input())
for _ in range(t):
	(a, b) = [int(i) for i in input().split()]
	t = a + b
	s = abs(a - b)
	if s >= 2:
		t += s - 1
	print(t)


cases = int(input())
while cases:
	cases -= 1
	(a, b) = map(int, input().split())
	if abs(a - b) <= 1:
		print(a + b)
	else:
		print(max(a, b) * 2 - 1)


testCase = int(input())
for i in range(testCase):
	info = input()
	info = info.split(' ')
	x = int(info[0])
	y = int(info[1])
	if x < y:
		selisih = y - x
		ans = x * 2 + (selisih * 2 - 1)
		print(ans)
	elif x > y:
		selisih = x - y
		ans = y * 2 + (selisih * 2 - 1)
		print(ans)
	else:
		ans = x + y
		print(ans)


import sys
import math
import bisect
from math import floor, sqrt, log
from collections import defaultdict
scanf = lambda n: [int(i) for i in sys.stdin.readline().split()][:n]
cin = lambda : map(int, sys.stdin.readline().split())
read_int = lambda : int(sys.stdin.readline())
read_string = lambda : sys.stdin.readline()
cout = lambda tt, x: sys.stdout.write('Case #' + str(tt) + ': ' + str(x) + '\n')
MOD = 1000000007

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

def mod_inverse(a, n):
	N = n
	xx = 0
	yy = 1
	y = 0
	x = 1
	while n > 0:
		q = a // n
		t = n
		n = a % n
		a = t
		t = xx
		xx = x - q * xx
		x = t
		t = yy
		yy = y - q * yy
		y = t
	x %= N
	x += N
	x %= N
	return 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 * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	return prime

def solve():
	(x, y) = cin()
	if x == y:
		print(2 * x)
	else:
		print(2 * min(x, y) + 2 * (max(x, y) - min(x, y)) - 1)
no_of_testcases = read_int()
for testcase in range(1, no_of_testcases + 1):
	solve()


ress = []

def count_trip(dest):
	dest = list(map(abs, dest))
	res = 0
	for n in range(min(dest)):
		res += 2
	res += (max(dest) - min(dest)) * 2 - 1 if dest[0] != dest[1] else 0
	return res
for t in range(int(input())):
	(x, y) = map(int, input().split(' '))
	ress += [count_trip((x, y))]
print(*ress, sep='\n')


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split(' '))
	if x == y:
		z = 1
	else:
		z = abs(abs(x) - abs(y))
	res = abs(x) + abs(y) + (z - 1)
	print(res)


TestCase = int(input())
for i in range(TestCase):
	(a, b) = map(int, input().split())
	if a == b or a == b - 1 or a - 1 == b:
		print(a + b)
	elif a > b:
		print(b * 2 + (a - b) * 2 - 1)
	else:
		print(a * 2 + (b - a) * 2 - 1)


import sys, collections, math, itertools, random
INF = sys.maxsize

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

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

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	(x, y) = get_ints()
	if x == y:
		print(x + y)
	elif x == 0 and y == 0:
		print(0)
	elif abs(x - y) <= 1:
		print(x + y)
	else:
		print(x + y + max(x, y) - (min(x, y) + 1))


def robot():
	(x, y) = map(int, input().split())
	x = abs(x)
	y = abs(y)
	t = abs(x - y)
	if t <= 1:
		ans = x + y
	else:
		k = min(x, y)
		ans = 2 * k + t * 2 - 1
	lst.append(ans)
lst = []
n = int(input())
for i in range(n):
	robot()
for i in range(n):
	print(lst[i])


t = int(input())
for i in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	print((a - b) * 2 - 1 * (a != b) + 2 * b) if a > b else print((b - a) * 2 - 1 * (a != b) + 2 * a)


for t in range(int(input())):
	(x, y) = map(int, input().split())
	ans = x + y
	if abs(x - y) > 1:
		ans += abs(x - y) - 1
	print(ans)


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	print(n + m + max(0, abs(m - n) - 1))


t = int(input())
for _ in range(t):
	(x, y) = (abs(int(number)) for number in input().split(' '))
	if x > y:
		result = 2 * y + 2 * (x - y) - 1
	elif y > x:
		result = 2 * x + 2 * (y - x) - 1
	else:
		result = 2 * x
	print(result)


for _ in range(int(input())):
	(n, m) = [int(c) for c in input().split()]
	if n == m:
		print(2 * n)
	else:
		print(max(n, m) + max(n, m) - 1)


for _ in range(int(input())):
	data = list(map(int, input().split()))
	(x, y) = (data[0], data[1])
	if x == y:
		print(2 * abs(x))
	else:
		print(2 * max(abs(x), abs(y)) - 1)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x == y:
		print(2 * x)
	else:
		if x < y:
			(m, ma) = (x, y)
		else:
			(m, ma) = (y, x)
		result = m * 2
		result += ma - m
		result += ma - m - 1
		print(result)