You are given two integers $a$ and $b$. You can perform a sequence of operations: during the first operation you choose one of these numbers and increase it by $1$; during the second operation you choose one of these numbers and increase it by $2$, and so on. You choose the number of these operations yourself.

For example, if $a = 1$ and $b = 3$, you can perform the following sequence of three operations:   add $1$ to $a$, then $a = 2$ and $b = 3$;  add $2$ to $b$, then $a = 2$ and $b = 5$;  add $3$ to $a$, then $a = 5$ and $b = 5$. 

Calculate the minimum number of operations required to make $a$ and $b$ equal. 


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of test cases.

The only line of each test case contains two integers $a$ and $b$ ($1 \le a, b \le 10^9$).


-----Output-----

For each test case print one integer — the minimum numbers of operations required to make $a$ and $b$ equal. 


-----Example-----
Input
3
1 3
11 11
30 20

Output
3
0
4



-----Note-----

First test case considered in the statement.

In the second test case integers $a$ and $b$ are already equal, so you don't need to perform any operations.

In the third test case you have to apply the first, the second, the third and the fourth operation to $b$ ($b$ turns into $20 + 1 + 2 + 3 + 4 = 30$).

Source: codeforces | Difficulty: MEDIUM
Tags: Mathematics

Greedy algorithms


Solutions:
for _ in range(int(input())):
	a = sorted(list(map(int, input().split())))
	r = a[1] - a[0]
	r = int(r ** 0.5)
	k = r * (r + 1) // 2
	while not (a[0] - a[1] + k >= 0 and (a[0] - a[1] + k) % 2 == 0):
		r += 1
		k = r * (r + 1) // 2
	print(r)


import sys
readline = sys.stdin.readline

def calc(x):
	if x == 0:
		return 0
	ng = 0
	ok = 10 ** 5
	while abs(ok - ng) > 1:
		med = (ok + ng) // 2
		S = med * (med + 1) // 2
		if abs(x) <= S:
			ok = med
		else:
			ng = med
	for i in range(5):
		if (ok + i) * (ok + 1 + i) // 2 % 2 == x % 2:
			break
	return ok + i
T = int(readline())
Ans = [None] * T
for qu in range(T):
	(a, b) = map(int, readline().split())
	Ans[qu] = calc(a - b)
print('\n'.join(map(str, Ans)))


def diff(a, b):
	return int(abs(a - b))

def check(a):
	if a < 0:
		return False
	s = str(a)
	for x in range(0, len(s)):
		if s[x] == '.':
			if s[x + 1] == '0':
				return True
			else:
				return False

def value(n):
	return int(n * (n + 1) / 2)

def calculate(a, b):
	d = diff(a, b)
	x = -1
	n = 0
	while x == -1:
		p = (value(n) - d) / 2
		if check(p):
			return n
		else:
			x = -1
			n = n + 1
l = []
size = int(input())
for k in range(0, size):
	(m, n) = map(str, input().split())
	l.append((int(m), int(n)))
for k in l:
	print(calculate(k[0], k[1]))


import math
t = int(input())
while t != 0:
	(a, b) = map(int, input().split())
	diff = max(a, b) - min(a, b)
	if diff % 2 == 0:
		x = math.ceil((math.sqrt(1 + 8 * diff) - 1) / 2)
		if x * (x + 1) / 2 % 2 != 0:
			while x * (x + 1) / 2 % 2 != 0:
				x += 1
		print(x)
	else:
		x = math.ceil((math.sqrt(1 + 8 * diff) - 1) / 2)
		if x * (x + 1) / 2 % 2 == 0:
			while x * (x + 1) / 2 % 2 == 0:
				x += 1
		print(x)
	t -= 1


import math
t = int(input())
for case in range(t):
	(a, b) = [int(x) for x in input().split(' ')]
	d = abs(a - b)
	ans = int(-1 + 1 * math.sqrt(1 + 8 * d)) // 2
	if ans * (ans + 1) // 2 < d:
		ans += 1
	if (ans * (ans + 1) // 2 - d) % 2 == 1:
		ans += 1
	if (ans * (ans + 1) // 2 - d) % 2 == 1:
		ans += 1
	print(ans)


t = int(input())

def bin_search(d, lo, hi):
	if lo + 1 == hi:
		return hi
	mid = (lo + hi) // 2
	if mid * (mid + 1) // 2 >= d:
		hi = mid
	else:
		lo = mid
	return bin_search(d, lo, hi)
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	d = abs(a - b)
	if d == 0:
		print(0)
		continue
	count = bin_search(d, 0, 10 ** 6)
	while count * (count + 1) // 2 % 2 != d % 2:
		count += 1
	print(count)


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

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

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

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

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

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

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

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

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(a, b) = sp()
	diff = abs(a - b)
	for i in range(100001):
		temp = i * (i + 1) // 2
		if temp >= diff and (not temp + a + b & 1):
			out(i)
			break


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	i = 0
	while True:
		x = i * (i + 1) // 2
		r = a + b + x
		if r % 2 == 0 and r / 2 >= a and (r / 2 >= b):
			print(i)
			break
		i += 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	if d == 0:
		print(0)
		continue
	i = 1
	while 1:
		if i * (i + 1) // 2 >= d and i * (i + 1) // 2 % 2 == d % 2:
			break
		i += 1
	print(i)


def main():
	t = int(input())
	for line in range(t):
		(a, b) = (int(x) for x in input().split())
		print(solver(a, b))

def solver(a, b):
	diff = abs(a - b)
	total = 0
	x = 0
	while not (total >= diff and (total - diff) % 2 == 0):
		x += 1
		total += x
	return x
main()


import math
elem = int(input())

def quad(diff):
	d = 1 + 4 * 2 * diff
	solution1 = (-1 - math.sqrt(d)) / 2
	solution2 = (-1 + math.sqrt(d)) / 2
	if solution1 > 0:
		return solution1
	else:
		return solution2
for x in range(elem):
	ar = []
	for el in input().split(' '):
		ar.append(int(el))
	count = 0
	if ar[0] == ar[1]:
		print(count)
		continue
	diff = abs(ar[0] - ar[1])
	odd = diff % 2
	i = math.floor(quad(diff) - 1)
	while True:
		if i * (i + 1) / 2 == diff:
			print(i)
			break
		if i * (i + 1) / 2 > diff:
			if (i * (i + 1) / 2 - 1) % 2 != odd:
				print(i)
				break
		i = i + 1


from math import inf

def solve():
	global s, a, b
	if b - a == 0:
		return 0
	x = a
	for i in range(100000):
		x += i
		if x - b >= 0 and (x - b) % 2 == 0:
			return i

def read_input():
	global a, b
	(a, b) = list(map(int, input().split()))
	(a, b) = (min(a, b), max(a, b))

def main():
	for _ in range(int(input())):
		read_input()
		print(solve())
main()


i = input
for _ in range(int(i())):
	(a, b) = map(int, i().split())
	d = abs(a - b)
	for r in range(99999):
		if r * (r + 1) >= 2 * d and (r + 1) % 4 // 2 == d % 2:
			print(r)
			break


for i in range(int(input())):
	(a, b) = map(int, input().split())
	temp1 = max(a, b) - min(a, b)
	n = 0
	n = int((-1 + (1 + temp1 * 8) ** 0.5) // 2)
	while True:
		s = n * (2 + n - 1) // 2
		temp2 = s - temp1
		if temp2 >= 0 and temp2 % 2 == 0:
			break
		n += 1
	print(int(n))


l = []
curr = 0
while 1:
	x = curr * (curr + 1) // 2
	if x > 10 ** 10:
		break
	l.append(x)
	curr += 1
t = int(input())
for you in range(t):
	lo = input().split()
	a = int(lo[0])
	b = int(lo[1])
	diff = max(a, b) - min(a, b)
	for i in range(len(l)):
		if l[i] >= diff and (l[i] - diff) % 2 == 0:
			ans = i
			break
	print(ans)


def solve():
	t = int(input())
	for case in range(t):
		(a, b) = map(int, input().split())
		if a > b:
			(a, b) = (b, a)
		(a, b) = (0, b - a)
		if b == 2:
			print(3)
			continue
		cur = 0
		while a < b:
			cur += 1
			a += cur
		if (a - b) % 2 == 1:
			tmp = cur + 1 + a - b
			if tmp % 2 == 0 and tmp / 2 <= cur:
				cur += 1
			else:
				cur += 2
		print(cur)
solve()


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	d = a - b
	n = (-1 + (1 + 8 * d) ** 0.5) // 2
	k = d - (n * n + n) // 2
	if k != 0:
		n = n + 1
		k = (n * n + n) // 2 - d
	if k % 2 == 0:
		print(round(n))
	elif (n + 1) % 2 == 0:
		print(round(n + 2))
	else:
		print(round(n + 1))


from math import sqrt, ceil, floor
t = int(input())
for q in range(t):
	(a, b) = map(int, input().split())
	if b > a:
		(a, b) = (b, a)
	a -= b
	n = floor(((1 + 8 * a) ** 0.5 - 1) / 2)
	while (n * (n + 1) / 2 + a) % 2 == 1 or n * (n + 1) / 2 < a:
		n += 1
	print(n)


import math
for _ in [0] * int(input()):
	(a, b) = list(map(int, input().split()))
	c = [b - a, a - b][a > b]
	sqrtc = int(math.sqrt(2 * c))
	if c == sqrtc * (sqrtc + 1) // 2:
		print(sqrtc)
	else:
		while sqrtc * (sqrtc + 1) // 2 < c or not sqrtc * (sqrtc + 1) // 2 % 2 == c % 2:
			sqrtc += 1
		print(sqrtc)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	s = 1
	c = 1
	if d == 0:
		print(0)
	else:
		while s < d or s % 2 != d % 2:
			c += 1
			s = c * (c + 1)
			s /= 2
		print(c)


from math import sqrt
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == k:
		print(0)
		continue
	if k > n:
		(n, k) = (k, n)
	x = 2 * (n - k)
	p = (-1 + int(sqrt(1 + 4 * x))) // 2
	if p * (p + 1) == x:
		print(p)
		continue
	x = x // 2
	if x == 2:
		print(3)
		continue
	if x == 4:
		print(3)
		continue
	i = 1
	sm = 0
	while True:
		sm += i
		if sm >= x:
			break
		i += 1
	k = i - 1
	sm = sm - k - 1
	if k % 2 == 1:
		if (x - sm) % 2 == 1:
			print(k + 2)
		else:
			print(k + 1)
	if k % 2 == 0:
		if (x - sm) % 2 == 1:
			print(k + 1)
		else:
			print(k + 3)


T = int(input())
while T > 0:
	(a, b) = map(int, input().split())
	if a > b:
		diff = a - b
	else:
		diff = b - a
	op = 0
	sums = 0
	while True:
		sums = sums + op
		if sums >= diff and (sums - diff) % 2 == 0:
			print(op)
			break
		op = op + 1
	T = T - 1


import math
T = int(input())
for i in range(T):
	(a, b) = map(int, input().strip().split())
	p = abs(a - b)
	if p == 0:
		print(0)
		continue
	n = int((-1 + math.sqrt(1 + 8 * p)) / 2)
	for j in range(n - 1, n + 5):
		x = j * (j + 1) / 2
		if (x - p) % 2 == 0 and j > 0 and (x >= p):
			ans = j
			break
	print(int(ans))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	ans = 0
	while d > 0 or -d % 2 or -d // 2 > ans:
		ans += 1
		d = abs(d) - ans
	print(ans)


t = int(input())
for i in range(0, t):
	(a, b) = map(int, input().split())
	resta = abs(a - b)
	if resta % 2 == 0:
		k = int((2 * resta) ** 0.5)
		suma = int(k * (k + 1) / 2)
		while suma < resta:
			k += 1
			suma = int(k * (k + 1) / 2)
		while suma % 2 != 0:
			k += 1
			suma = int(k * (k + 1) / 2)
	else:
		k = int((2 * resta) ** 0.5)
		suma = int(k * (k + 1) / 2)
		while suma < resta:
			k += 1
			suma = int(k * (k + 1) / 2)
		while suma % 2 != 1:
			k += 1
			suma = int(k * (k + 1) / 2)
	print(k)


def add(res, d):
	sum = res * (res + 1) // 2
	if sum < d:
		return 0
	if sum % 2 == d % 2:
		return 1
	else:
		return 0
for _ in range(int(input())):
	(a, b) = (int(x) for x in input().split())
	d = abs(a - b)
	if d == 0:
		print(0)
		continue
	res = 1
	while not add(res, d):
		res = res + 1
	print(res)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	for i in range(10 ** 5):
		if i * (i + 1) // 2 >= d and (i * (i + 1) // 2 - d) % 2 == 0:
			print(i)
			break


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	diff = abs(a - b)
	val = math.ceil((-1 + math.sqrt(1 + 8 * diff)) / 2)
	mod = diff % 2
	modi = math.ceil(val / 2) % 2
	if mod == modi:
		print(val)
	elif val % 2 == 0:
		print(val + 1)
	else:
		print(val + 2)


from math import ceil, sqrt
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	x = ceil((sqrt(8 * d + 1) - 1) / 2)
	for i in range(4):
		if d % 2 == 0 and ((x + i) % 4 == 0 or (x + i) % 4 == 3):
			print(x + i)
			break
		if d % 2 == 1 and ((x + i) % 4 == 1 or (x + i) % 4 == 2):
			print(x + i)
			break


for _ in range(int(input())):
	(a, b) = sorted(map(int, input().split()))
	if a == b:
		print(0)
		continue
	(ans, s) = (0, 0)
	while True:
		ans += 1
		s += ans
		if s < b - a:
			continue
		if (s - b + a) % 2:
			continue
		x = (s - b + a) // 2
		if x <= s:
			print(ans)
			break


t = int(input())
for i in range(t):
	line = input()
	(a, b) = (int(line.strip().split()[0]), int(line.strip().split()[1]))
	d = abs(a - b)
	summ = 0
	i = 0
	while summ < d:
		i += 1
		summ += i
	if (summ - d) % 2 == 0:
		print(i)
	elif i % 2 == 0:
		print(i + 1)
	else:
		print(i + 2)


exec(int(input()) * 'a,b=map(int,input().split());d=abs(a-b);i=0\nwhile d%2or d>0:i+=1;d-=i\nprint(i);')


from math import *

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

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans
for __ in range(int(input())):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	for i in range(100010):
		if i * (i + 1) // 2 >= d and i * (i + 1) // 2 % 2 == d % 2:
			print(i)
			break


t = int(input())
while t > 0:
	(e, d) = [int(i) for i in input().split()]
	k = 10000000000000000
	a = max(e, d)
	b = min(e, d)
	diff = abs(a - b)
	sum = diff
	inte = 0
	for i in range(1, k):
		if diff == 0:
			i -= 1
			break
		inte += i
		if inte < sum:
			pass
		elif inte == sum:
			break
		elif (inte + sum) % 2 == 0:
			break
	print(i)
	t -= 1


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
t = rint()
for _ in range(t):
	(a, b) = sorted(rints())
	mn = b - a if a % 2 == b % 2 else b - a + 2
	for i in range(10 ** 6):
		s = i * (i + 1) // 2
		if s >= b - a and (s - (b - a)) % 2 == 0:
			print(i)
			break


def bin(x):
	l = 0
	r = 1000000000
	lst = 0
	while l + 1 < r:
		m = (l + r) // 2
		tc = m * 4
		if (tc + 1) * (tc // 2) >= x:
			r = m
			lst = tc
		else:
			l = m
	return lst

def bin1(x):
	l = 1
	r = 1000000000
	lst = 0
	while l + 1 < r:
		m = (l + r) // 2
		tc = m * 2
		if (tc + 1) * (tc // 2) >= x:
			r = m
			lst = tc
		else:
			l = m
	return lst
for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x == y:
		print(0)
		continue
	d = abs(x - y)
	if d % 2 == 0:
		k = bin(d)
		kk = k - 1
		if (kk + 1) * (kk // 2) + (kk + 1) // 2 >= d:
			print(kk)
		else:
			print(k)
	else:
		k = bin1(d)
		if k // 2 % 2 == 1:
			kk = k - 1
			if (kk + 1) * (kk // 2) + (kk + 1) // 2 >= d:
				print(kk)
			else:
				print(k)
		else:
			kk = k - 2
			if (kk + 1) * (kk // 2) >= d:
				kkk = kk - 1
				if (kkk + 1) * (kkk // 2) + (kkk + 1) // 2 >= d:
					print(kkk)
				else:
					print(kk)
			else:
				print(k + 1)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	diff = abs(a - b)
	for i in range(0, 100000):
		if i * (i + 1) // 2 >= diff and (i * (i + 1) // 2 - diff) % 2 == 0:
			print(i)
			break


import sys
input = sys.stdin.buffer.readline
import math
from collections import defaultdict

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

def main():
	N = int(input())
	for k in range(N):
		(a, b) = getlist()
		(a, b) = sorted([a, b])
		M = b - a
		x = None
		for i in range(10 ** 5):
			if i * (i + 1) <= 2 * M and 2 * M < (i + 1) * (i + 2):
				x = i
				break
		if x * (x + 1) == 2 * M:
			print(x)
		elif (int((x + 1) * (x + 2) // 2) - M) % 2 == 0:
			print(x + 1)
		elif x % 2 == 0:
			print(x + 3)
		else:
			print(x + 2)
main()


for _ in range(int(input())):
	ab = [int(x) for x in input().split()]
	a = ab[0]
	b = ab[1]
	diff = abs(a - b)
	mi = min(a, b)
	ma = max(a, b)
	arr = [0]
	ans = -1
	for i in range(diff + 2):
		ne = arr[-1] + i
		arr.append(ne)
		if ne + mi == ma:
			ans = i
			break
		if ne - diff > 0 and (ne - diff) % 2 == 0:
			ans = i
			break
	print(ans)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	diff = b - a
	n = int((1 + 8 * (b - a)) ** 0.5 - 1) // 2
	if n * (n + 1) // 2 != diff:
		n += 1
		while (n * (n + 1) // 2 - diff) % 2 != 0:
			n += 1
	print(n)


mod = 10 ** 9 + 7
import math
from bisect import bisect_left as bl
from collections import Counter
from itertools import combinations

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

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

def mc2(s):
	return s * (s - 1) // 2
for _ in range(int(input())):
	(a, b) = ain()
	if a > b:
		(a, b) = (b, a)
	diff = b - a
	if diff == 0:
		print('0')
		continue
	s = 1
	sqn = s * (s + 1) // 2
	while sqn < diff or (sqn - diff) % 2 == 1:
		s += 1
		sqn = s * (s + 1) // 2
	print(s)


t = int(input())
for _ in range(t):
	(a, b) = [int(i) for i in input().split()]
	i = 0
	while i * (i + 1) // 2 < abs(a - b) or (i * (i + 1) // 2 - abs(a - b)) % 2 == 1:
		i += 1
	print(i)


def func1(a, b):
	if a == b:
		return 0
	d = b - a
	n = (-1 + (1 + 8 * d) ** 0.5) / 2
	if n != int(n):
		n = int(n) + 1
	s = n * (n + 1) / 2
	if (s - d) % 2 == 0:
		return n
	if (n + 1) % 2 == 1:
		return n + 1
	return n + 2
t = int(input())
k = []
for i in range(t):
	lst = list(map(int, input().split()))
	b = max(lst)
	a = min(lst)
	k.append(func1(a, b))
for i in k:
	print(int(i))


cum_sum = [0] * 47000
cum_sum[1] = 1
for i in range(2, 47000):
	cum_sum[i] = cum_sum[i - 1] + i
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	delta = max(a, b) - min(a, b)
	cnt = cum_sum.index([el for el in cum_sum if el <= delta][-1])
	eq = a + b + cum_sum[cnt]
	while eq % 2 != 0 or eq // 2 < max(a, b):
		cnt += 1
		eq += cnt
	print(cnt)


def check(r, d):
	s = r * (r + 1) // 2
	return s >= d and s % 2 == d % 2
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
		continue
	ans = 1
	while not check(ans, abs(a - b)):
		ans += 1
	print(ans)


def ab(a, b):
	if a == b:
		return 0
	if a > b:
		(a, b) = (b, a)
	for i in range(100000):
		a = a + i
		if a == b:
			return i
		elif a > b:
			if (a - b) % 2 == 0:
				return i
			elif (a - b) % 2 != 0:
				if (i + 1) % 2 != 0:
					i = i + 1
					return i
				elif (i + 1) % 2 == 0:
					i = i + 2
					return i
times = int(input())
for i in range(times):
	nums = input().split(' ')
	print(ab(int(nums[0]), int(nums[1])))


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	else:
		if a < b:
			(a, b) = (b, a)
		for i in range(1, a + 1):
			x = i * (i + 1) // 2
			if a - b <= x and (a - b) % 2 == x % 2:
				print(i)
				break


import sys
import collections
from collections import Counter
import itertools
import math
import timeit

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

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

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

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

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

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

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

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

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

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

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

def ddl():
	return collections.defaultdict(list)
t = ii()
for _ in range(t):
	(a, b) = mi()
	m = abs(a - b)
	x = ceil(math.sqrt(8 * m + 1) - 1, 2)
	r = x * (x + 1) // 2
	if r == m or (r - m) % 2 == 0:
		print(x)
	elif (r - m) % 2 and x % 2 == 0:
		print(x + 1)
	else:
		print(x + 2)


sum_first_n = [0] * 100001
for i in range(1, 100001):
	sum_first_n[i] = i + sum_first_n[i - 1]
for case in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	for i in range(0, 100001):
		x = a + b + sum_first_n[i]
		if x % 2 == 0 and x // 2 >= a and (x // 2 >= b):
			print(i)
			break


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	dif = abs(a - b)
	if dif == 0:
		print(0)
		continue
	i = 1
	while True:
		n = i * (i + 1) // 2
		if n % 2 != dif % 2:
			i += 1
			continue
		elif dif > n:
			i += 1
			continue
		else:
			print(i)
			break


for i in range(int(input())):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	su = a + b
	sq = int(pow(d, 0.5))
	if a == b:
		print(0)
	else:
		while 1:
			st = sq * (sq + 1) // 2
			if st >= d:
				if (su + st) % 2 == 0:
					break
			sq = sq + 1
		print(sq)


t = int(input())
for j in range(t):
	z = input().split(' ')
	a = abs(int(z[0]) - int(z[1]))
	if a % 2 == 0:
		i = int(a ** 0.5)
		while not (a <= int((i ** 2 + i) / 2) and (i % 4 == 0 or i % 4 == 3)):
			i -= -1
	else:
		i = int(a ** 0.5)
		while not (a <= int((i ** 2 + i) / 2) and (i % 4 == 1 or i % 4 == 2)):
			i -= -1
	print(i)


def check(num):
	temp = num * (num + 1) // 2
	if temp <= b - a:
		return 1
	else:
		return 0

def bin_search(l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if check(mid):
			l = mid
		else:
			r = mid - 1
	return l
MAX = int(1000000000.0) + 1
t = int(input())
for _ in range(t):
	ans = 0
	(a, b) = [int(i) for i in input().split()]
	if a == b:
		print(0)
	else:
		m = max(a, b)
		mi = min(a, b)
		a = mi
		b = m
		x = bin_search(1, MAX)
		t1 = x * (x + 1) // 2
		t2 = a + t1
		diff = b - t2
		if diff == 0:
			print(x)
		else:
			t3 = (x + 1) * (x + 2) // 2
			d1 = a + t3 - b
			y = x + 1
			if d1 % 2 == 0:
				print(x + 1)
			else:
				ans = y
				y += 1
				ans += 1
				d1 += y
				if d1 % 2 != 0:
					ans += 1
				print(min(ans, x + 2 * diff))


t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	d = abs(a - b)
	r = 0
	while r * (r + 1) < 2 * d or ((r + 1) // 2 - d) % 2:
		r += 1
	print(r)


t = int(input())
import math
for i in range(t):
	(a, b) = map(int, input().split())
	dif = abs(b - a)
	j = 0
	sum = 2 * dif
	j = math.sqrt(sum)
	k = math.floor(j)
	if j - k < 0.5:
		j = k
	else:
		j = k + 1
	sum = j * (j + 1)
	sum /= 2
	while abs(sum - dif) % 2 != 0:
		j += 1
		sum += j
	print(j)


import math
t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	if a == b:
		print(0)
	else:
		c = abs(a - b)
		n = math.ceil((math.sqrt(8 * c + 1) - 1) / 2)
		while (n * (n + 1) / 2 + c) % 2 == 1:
			n += 1
		print(int(n))


import sys
input = sys.stdin.readline

def solveeven(border):
	l = -1
	r = 10 ** 5
	while r - l > 1:
		m = (r + l) // 2
		num = m * 2 if m % 2 == 0 else m * 2 + 1
		if num * (num + 1) // 2 >= border:
			r = m
		else:
			l = m
	return r * 2 if r % 2 == 0 else r * 2 + 1

def solveodd(border):
	l = -1
	r = 10 ** 5
	while r - l > 1:
		m = (r + l) // 2
		num = m * 2 if m % 2 == 1 else m * 2 + 1
		if num * (num + 1) // 2 >= border:
			r = m
		else:
			l = m
	return r * 2 if r % 2 == 1 else r * 2 + 1
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
for (a, b) in Query:
	diff = abs(a - b)
	if diff % 2 == 0:
		print(solveeven(diff))
	else:
		print(solveodd(diff))


def func(m):
	return m * (m + 1) // 2

def check(m, d):
	return func(m) >= d
for t in range(int(input())):
	(a, b) = map(int, input().split())
	d = abs(b - a)
	low = 0
	high = 1000000000
	ans = None
	while low <= high:
		mid = (low + high) // 2
		if check(mid, d):
			ans = mid
			high = mid - 1
		else:
			low = mid + 1
	while func(ans) % 2 != d % 2:
		ans += 1
	print(ans)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq 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 = 998244353
EPS = 1e-06

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()]
sums = [0, 1]
s = 1
c = 2
while s < 10 ** 9:
	s += c
	c += 1
	sums.append(s)
for _ in range(Int()):
	(a, b) = sorted(value())
	b -= a
	ans = 0
	s = 0
	while True:
		if s >= b and (s - b) % 2 == 0:
			break
		ans += 1
		s += ans
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def solve(n):
	if n * (n + 1) // 2 < dif:
		return False
	return n * (n + 1) // 2 % 2 == dif % 2
for _ in range(int(ri())):
	(a, b) = Ri()
	if a > b:
		(a, b) = (b, a)
	dif = b - a
	(l, r) = (0, 50000)
	ans = 50000
	for i in range(0, 50000):
		if solve(i):
			ans = i
			break
	print(ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(aa, bb) = (min(a, b), max(a, b))
	c = bb - aa
	i = 0
	ans = 0
	if c == 0:
		print(0)
	else:
		while 1:
			i += 1
			ans += i
			if ans >= c and (ans - c) % 2 == 0:
				print(i)
				break


def main():
	tc = int(input())
	for _ in range(tc):
		(a, b) = [int(x) for x in input().split()]
		if a == b:
			print(0)
			continue
		if a > b:
			(a, b) = (b, a)
		cnt = 1
		while True:
			a += cnt
			if a >= b and (a - b) % 2 == 0:
				break
			cnt += 1
		print(cnt)
	return
main()


def ok(d):
	temp = 0
	for i in range(1000000000):
		temp += i
		if temp >= d and (temp - d) % 2 == 0:
			return i
for _ in range(int(input())):
	(a, b) = (int(x) for x in input().split())
	if a == b:
		print('0')
		continue
	d = abs(a - b)
	print(ok(d))


def solve():
	t = int(input())
	for _ in range(t):
		(a, b) = map(int, input().split())
		d = abs(a - b)
		n = int((2 * d) ** 0.5)
		res = n * (n + 1) // 2
		while res % 2 != d % 2 or res < d:
			n += 1
			res = n * (n + 1) // 2
		print(n)
solve()


for tcase in range(int(input())):
	(a, b) = list(map(int, input().split()))
	if a == b:
		print(0)
	else:
		delta = abs(b - a)
		i = 1
		sm = 0
		while sm < delta:
			sm += i
			i += 1
		while sm % 2 != delta % 2:
			sm += i
			i += 1
		print(i - 1)


def times(a, b):
	if a == b:
		return 0
	val = abs(b - a)
	sum = 1
	i = 1
	while True:
		while sum <= val:
			if sum == val:
				return i
			else:
				i += 1
				sum += i
		val += 2
t = int(input())
for i in range(t):
	(a, b) = map(int, input().strip().split())
	print(times(a, b))


for i in range(int(input())):
	(inp1, inp2) = map(int, input().split())
	a1 = max(inp1, inp2)
	a2 = min(inp1, inp2)
	if a1 == a2:
		print(0)
		continue
	else:
		i = int(((1 + 8 * (a1 - a2)) ** 0.5 - 1) // 2)
		j = 1
		while j:
			if i * (i + 1) // 2 >= a1 - a2:
				if (a1 + a2 + i * (i + 1) // 2) % 2 == 0:
					print(i)
					j = 0
					continue
			i = i + 1


def find_min_n_bigger_than(diff):
	(l, r) = (0, 10 ** 5)
	while r - l > 1:
		mid = (l + r) // 2
		n_sum = int(mid * (mid + 1) / 2)
		if n_sum < diff:
			l = mid
		else:
			r = mid
	return r

def solve(a, b):
	(a, b) = (max(a, b), min(a, b))
	if a == b:
		return 0
	candidate = find_min_n_bigger_than(a - b)
	qq = [candidate + i for i in range(4)]
	for ss in qq:
		if ss * (ss + 1) / 2 % 2 == (a - b) % 2:
			return ss
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	print(solve(a, b))


import sys
n = int(sys.stdin.readline().rstrip())
ab = map(int, sys.stdin.read().split())
ab = list(zip(*[ab] * 2))

def main():
	for (a, b) in ab:
		x = abs(b - a)
		if x == 0:
			yield 0
			continue
		l = 0
		r = x + 1
		while l + 1 < r:
			m = (l + r) // 2
			if (1 + m) * m // 2 >= x:
				r = m
			else:
				l = m
		if ((1 + r) * r // 2 - x) % 2 == 0:
			yield r
		elif r + 1 & 1:
			yield (r + 1)
		else:
			yield (r + 2)
ans = main()
print(*ans, sep='\n')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = abs(a - b)
	d = (-1 + (1 + 8 * c) ** 0.5) / 2
	if d == int(d):
		print(int(d))
	else:
		d = int(d)
		d += 1
		e = abs(c - d * (d + 1) // 2)
		if e % 2 == 0:
			print(d)
		elif d % 2 == 0:
			print(d + 1)
		else:
			print(d + 2)


from math import sqrt
for _ in range(int(input())):
	(a, b) = map(int, input().strip().split())
	if a == b:
		print(0)
		continue
	(a, b) = (min(a, b), max(a, b))
	d = b - a
	n1 = (-1 + sqrt(1 + 8 * d)) / 2
	b = int(n1)
	if int(n1) == n1:
		print(b)
		continue
	flag = False
	for i in range(b, 1000000000):
		k = i * (i + 1) / 2
		k1 = k - d
		if k1 >= 0 and k1 % 2 == 0:
			print(i)
			flag = True
			break
	if not flag:
		print(-1)


import sys

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(a, b) = mints()
	d = abs(a - b)
	if d == 0:
		return 0
	if d == 1:
		return 1
	s = 0
	for i in range(1, int(1000000000.0)):
		s += i
		if s >= d and s % 2 == d % 2:
			return i
	return 0
for i in range(mint()):
	print(solve())


def ok(i, diff):
	sum = i * (i + 1) / 2
	if sum < diff:
		return False
	return sum % 2 == diff % 2
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	i = 0
	while not ok(i, abs(a - b)):
		i += 1
	print(i)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	aa = max(a, b)
	bb = min(a, b)
	if aa == bb:
		print(0)
	else:
		x = aa - bb
		y = -1 + (1 + 8 * x) ** (1 / 2)
		if y / 2 == y // 2:
			print(int(y // 2))
		else:
			y = y // 2 + 1
			su = y * (y + 1) // 2
			while (su - x) % 2 != 0:
				y += 1
				su += y
			print(int(y))


from sys import stdin, stdout
import sys
from bisect import bisect_left, bisect_right
import heapq
t = int(stdin.readline().strip())
for _ in range(t):
	(a, b) = stdin.readline().strip().split(' ')
	(a, b) = (int(a), int(b))
	d = abs(a - b)
	t1 = 0
	i = 0
	while t1 < d or t1 % 2 != d % 2:
		i += 1
		t1 = i * (i + 1) // 2
	stdout.write(str(i) + '\n')


for t in range(int(input())):
	(a, b) = [int(j) for j in input().split()]
	delta = abs(a - b)
	z = 0
	while True:
		if z * (z + 1) // 2 >= delta:
			if z * (z + 1) // 2 % 2 == delta % 2:
				print(z)
				break
		z += 1


t = int(input())
for x in range(t):
	(a, b) = list(map(int, input().split()))
	(a, b) = (min(a, b), max(a, b))
	for i in range(10 ** 5):
		if i * (i + 1) // 2 >= b - a and (i * (i + 1) // 2 - (b - a)) % 2 == 0:
			print(i)
			break


t = int(input())
for x in range(t):
	(a, b) = sorted(map(int, input().split()))
	for i in range(10 ** 5):
		if i * (i + 1) // 2 >= b - a and (i * (i + 1) // 2 - (b - a)) % 2 == 0:
			print(i)
			break


def solve():
	(a, b) = map(int, input().split())
	if b < a:
		(a, b) = (b, a)
	c = abs(a - b)
	low = 0
	high = c + 4
	while low + 1 < high:
		mid = (low + high) // 2
		if mid * mid <= c:
			low = mid
		else:
			high = mid
	while True:
		d = a + low * (low + 1) // 2 - b
		if d >= 0 and d % 2 == 0:
			break
		low += 1
	print(low)
t = int(input())
for _ in range(t):
	solve()


for nt in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
		continue
	x = 1
	i = 1
	d = abs(a - b)
	while x < d or x % 2 != d % 2:
		i += 1
		x = i * (i + 1) // 2
	print(i)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *
from collections import defaultdict
getcontext().prec = 25
MOD = pow(10, 9) + 7
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	(n, k) = (min(n, k), max(n, k))
	z = abs(n - k)
	if n == k:
		print(0)
	else:
		s = 0
		i = 0
		while s < z or (s ^ z) % 2:
			i += 1
			s += i
		print(i)


import math
T = int(input())
for i in range(T):
	(A, B) = map(int, input().split())
	d = max(A, B) - min(A, B)
	dif = (math.sqrt(8 * d + 1) - 1) / 2
	if dif == int(dif):
		print(int(dif))
	else:
		delt = int(dif)
		(dela0, dela1) = (d - delt * (delt + 1) // 2, (delt + 2) * (delt + 1) // 2 - d)
		if dela1 % 2 == 0:
			print(delt + 1)
		elif (dela1 + delt) % 2 == 0:
			print(delt + 2)
		else:
			print(delt + 3)


q = int(input())
cache = {}
while q:
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	diff = abs(a - b)
	if cache.get(diff, None) is not None:
		print(cache.get(diff))
	else:
		start = 0
		value = 0
		while True:
			if start + value < diff:
				value = start + value
				start += 1
				continue
			if (start + value) % 2 == diff % 2:
				print(start)
				cache.update({diff: start})
				break
			value = start + value
			start += 1
	q -= 1


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

def solve(a, b):
	if a > b:
		(a, b) = (b, a)
	n = int(math.floor((-1 + math.sqrt(1 + 8 * (b - a))) / 2))
	if (n * n + n) // 2 == b - a:
		return n
	elif not (((n + 1) ** 2 + (n + 1)) // 2 - (b - a)) % 2:
		return n + 1
	else:
		if (n + 2) % 2 == 0:
			return n + 3
		return n + 2

def main():
	for _ in range(int(input().strip())):
		(a, b) = map(int, input().strip().split())
		print(solve(a, b))
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

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

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


def sol(res, d):
	sum = res * (res + 1) // 2
	if sum < d:
		return False
	return sum % 2 == d % 2
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	diff = abs(a - b)
	ans = 1
	if diff == 0:
		print(0)
	else:
		while sol(ans, diff) == False:
			ans += 1
		print(ans)


from sys import stdin
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	x = max(a, b) - min(a, b)
	s = 0
	ans = 0
	for i in range(0, 100000):
		s += i
		if s - x >= 0 and (s - x) % 2 == 0:
			ans = i
			break
	print(ans)


t = int(input())
from math import *

def fun(a):
	return a * (a + 1) // 2
for tt in range(t):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	if d == 0:
		print(0)
		continue
	q = int(sqrt(2 * d))
	l = []
	num = [q - 2, q - 1, q, q + 1, q + 2]
	for i in range(q - 2, q + 3):
		l.append(fun(i))
	for i in range(4):
		if l[i] == d:
			print(num[i])
			break
		elif l[i] < d < l[i + 1]:
			k = d - l[i]
			tem = num[i]
			if tem % 2 == 0:
				num1 = tem + 1
				num2 = tem + 3
			else:
				num1 = tem + 2
				num2 = tem + 1
			if k % 2 == 0:
				print(num2)
			else:
				print(num1)
	if l[4] == d:
		print(num[4])


from fractions import gcd
from math import ceil, inf
from collections import defaultdict, Counter, deque
from bisect import bisect, insort, bisect_left, bisect_right
mod = int(1000000000.0) + 7
mod_ = 998244353

def main():
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		(a, b) = sorted([a, b])
		diff = b - a
		if diff == 0:
			print(0)
			continue
		n = int(((1 + 8 * diff) ** 0.5 - 1) // 2)
		a += n * (n + 1) // 2
		if a == b:
			print(n)
		else:
			n += 1
			a += n
			while (a - b) % 2 != 0:
				n += 1
				a += n
			print(n)
main()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		print('0')
		continue
	j = 1
	s = a + b
	if abs(a - b) > 1000:
		k = int(abs((a - b) ** 0.5) * 1.4)
		s = a + b + (k + 1) * (k / 2)
		j = k + 1
	while j > 0:
		s = s + j
		if s >= max(a, b) * 2 and s % 2 == 0:
			print(j)
			break
		else:
			j += 1


import math

def find_smallest_addable(a, b):
	if a > b:
		diff = a - b
	else:
		diff = b - a
	if diff == 0:
		return 0
	n = math.ceil((-1 + math.sqrt(1 + 8 * diff)) / 2)
	while True:
		res = n * (n + 1) / 2
		if (res - diff) % 2 == 0:
			return n
		n += 1
useless = int(input())
for i in range(useless):
	(a, b) = [int(i) for i in input().split()]
	print(find_smallest_addable(a, b))


def cc(n):
	c = 0
	d = 0
	while d < n or (d - n) % 2 == 1:
		c += 1
		d = c * (c + 1) / 2
	return c
t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split(' ')))
	a = abs(a - b)
	print(cc(a))


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

def solve():
	(a, b) = sorted(map(int, input().split()))
	if a == b:
		print(0)
		return
	left = 0
	right = 10 ** 12
	while right - left > 1:
		mid = (right + left) // 2
		if mid * (mid + 1) // 2 >= b - a:
			right = mid
		else:
			left = mid
	while True:
		c = right * (right + 1) // 2
		if (a + b + c) % 2 == 0 and (a + b + c) // 2 >= b:
			print(right)
			return
		right += 1
t = int(input())
for i in range(t):
	solve()


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	m = max(a, b)
	n = min(a, b)
	if m >= n:
		diff = m - n
		x = math.ceil((-1 + (1 + 8 * diff) ** 0.5) / 2)
		while True:
			if (x * (x + 1) / 2 - diff) % 2 == 0:
				print(x)
				break
			x += 1
	else:
		print(0)


import math

def check(a, b, k):
	sa = (k * (k + 1) / 2 + b - a) / 2
	if sa < 0 or sa != int(sa) or sa - (b - a) < 0:
		return False
	return True

def proB(a, b):
	if a == b:
		return 0
	i = 1
	while True:
		if check(a, b, i):
			return i
		i += 1
t = int(input())
for i in range(t):
	arr = list(map(int, input().split()))
	(a, b) = arr
	print(proB(a, b))


from math import sqrt
for _ in range(int(input())):
	(a, b) = [int(i) for i in input().split()]
	diff = abs(a - b)
	n = int(sqrt(2 * diff))
	res = n * (n + 1) // 2
	while res % 2 != diff % 2 or res < diff:
		n += 1
		res = n * (n + 1) // 2
	print(n)


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	a = min(x, y)
	b = max(x, y)
	k = int((-1 + (1 + 4 * ((b - a) * 2)) ** 0.5) / 2)
	if (b - a) % 2 == 0:
		while True:
			if (k ** 2 + k) % 4 == 0 and (k ** 2 + k) // 2 - (b - a) >= 0:
				print(k)
				break
			k += 1
	else:
		while True:
			if (k ** 2 + k) % 4 == 2 and (k ** 2 + k) // 2 - (b - a) >= 0:
				print(k)
				break
			k += 1


t = int(input())
for test in range(t):
	(a, b) = [int(i) for i in input().split()]
	(a, b) = (max(a, b) - min(a, b), 0)
	sum = 0
	for i in range(10 ** 9):
		sum += i
		if a % 2 == sum % 2:
			if sum >= a:
				print(i)
				break


t = int(input())
for i in range(t):
	inp = list(map(int, input().split()))
	a = inp[0]
	b = inp[1]
	x = abs(a - b)
	if x == 0:
		print(0)
	else:
		t = 1
		while (x + t * (t + 1) // 2) % 2 != 0 or t * (t + 1) // 2 < x:
			t += 1
		print(t)


t = int(input())
lists = []
import math
for i in range(t):
	(a, b) = map(int, input().split())
	K = math.floor(math.sqrt(2 * abs(b - a)))
	if K * (K + 1) // 2 % 2 == abs(b - a) % 2 and K * (K + 1) // 2 >= abs(b - a):
		lists.append(K)
	else:
		while not (K * (K + 1) // 2 % 2 == abs(b - a) % 2 and K * (K + 1) // 2 >= abs(b - a)):
			K += 1
		lists.append(K)
for some in lists:
	print(some)


def answer(a, b):
	n = 10 ** 6
	for i in range(n):
		k = i * (i + 1) / 4 - abs(a - b) / 2
		if k == int(k) and k >= 0:
			return i
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	print(answer(a, b))


from time import sleep
t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	if a == b:
		print(0)
	else:
		if b > a:
			(a, b) = (b, a)
		x = 1
		d = a - b
		while True:
			sa = (x * (x + 1) // 2 - d) / 2
			sb = (x * (x + 1) // 2 + d) / 2
			if sa >= 0 and int(sa) == sa and (int(sb) == sb):
				print(x)
				break
			x += 1


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
int_input = lambda : int(stdin.readline())
string_input = lambda : stdin.readline()
multi_int_input = lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input = lambda : list(map(int, stdin.readline().split()))
string_list_input = lambda : list(string_input())
MOD = pow(10, 9) + 7
test = int_input()
for _ in range(test):
	(a, b) = multi_int_input()
	diff = abs(a - b)
	if diff == 0:
		print(0)
	else:
		sum = 0
		k = 1
		count = 0
		while not (sum >= diff and (sum - diff) % 2 == 0):
			sum += k
			k = k + 1
			count += 1
		print(count)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

def iinp():
	return int(inp())

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

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

def lmp():
	return list(mp())

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

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

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

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

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	(a, b) = sorted(mp())
	x = 0
	while a < b or (a - b) % 2 != 0:
		x += 1
		a += x
	print(x)


def solve():
	(a, b) = map(int, input().split())
	d = abs(a - b)
	if d == 0:
		print(0)
		return
	count = 1
	while True:
		sum = count * (count + 1) / 2
		if sum >= d and sum % 2 == d % 2:
			break
		count += 1
	print(count)
t = int(input())
for _ in range(t):
	solve()


arr = [0 for i in range(100002)]
summ = 1
for i in range(1, 100001):
	arr[i - 1] = summ
	summ += i + 1
t = int(input())
while t > 0:
	(a, b) = [int(i) for i in input().split()]
	if b > a:
		(a, b) = (b, a)
	diff = a - b
	if diff == 0:
		ans = 0
	else:
		for i in range(100000):
			if arr[i] < diff:
				continue
			elif arr[i] == diff:
				ans = i + 1
				break
			elif arr[i] - diff & 1 == 0:
				ans = i + 1
				break
	print(ans)
	t -= 1


t = int(input())
for _ in range(t):
	ans = 0
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a != b:
		for i in range(100000):
			s = i * (i + 1) // 2
			if s > 100000000000:
				break
			cv = a + b + s
			if cv % 2:
				continue
			if cv >= 2 * b:
				print(i)
				break
	else:
		print(0)


from math import sqrt
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	d = b - a
	n = 0
	while 1:
		if (n ** 2 + n + 2 * a - 2 * b) % 4 == 0 and (n ** 2 + n + 2 * a - 2 * b) // 4 >= 0 and ((n ** 2 + n + 2 * a - 2 * b) // 4 <= n * (n + 1) // 2):
			print(n)
			break
		n += 1


t = int(input())
for _ in range(t):
	nums = input().split(' ')
	a = int(nums[0])
	b = int(nums[1])
	d = abs(a - b)
	if d == 0:
		print(0)
		continue
	i = 1
	while True:
		sum = (i + 1) * i / 2
		if sum % 2 != d % 2:
			i += 1
			continue
		if d > sum:
			i += 1
			continue
		print(i)
		break


from math import ceil, sqrt
for _ in range(int(input())):
	(a, b) = sorted(list(map(int, input().split())))
	d = b - a
	n = ceil((sqrt(1 + 8 * d) - 1) / 2)
	while not (n * (n + 1) - 2 * d >= 0 and (n * (n + 1) - 2 * d) % 4 == 0):
		n += 1
	print(n)


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	(n, m) = map(int, stdin.readline().split())
	a = max(n, m)
	b = min(n, m)
	x = a - b
	for i in range(a + 1):
		s = i * (i + 1) // 2
		if s >= x and s % 2 == x % 2:
			break
	print(i)


import bisect
t = int(input())
p = [0] * (10 ** 5 + 1)
for i in range(1, 10 ** 5):
	p[i] = i + p[i - 1]
for i in range(t):
	(a, b) = map(int, input().split())
	c = abs(a - b)
	ans = bisect.bisect_left(p, c)
	while (c + p[ans]) % 2 == 1:
		ans += 1
	print(ans)


import math
t = int(input())
ans_list = []
for i in range(t):
	ans = 0
	(a, b) = map(int, input().split())
	dif = abs(a - b)
	if dif == 0:
		ans_list.append(ans)
	else:
		min_n = math.ceil((-1 + (1 + 8 * dif) ** 0.5) / 2)
		if min_n % 4 == 1 and dif % 2 == 0:
			ans = min_n + 2
		elif min_n % 4 == 2 and dif % 2 == 0:
			ans = min_n + 1
		elif min_n % 4 == 3 and dif % 2 == 1:
			ans = min_n + 2
		elif min_n % 4 == 0 and dif % 2 == 1:
			ans = min_n + 1
		else:
			ans = min_n
		ans_list.append(ans)
for i in range(t):
	print(ans_list[i])


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	d = abs(a - b)
	if d == 0:
		print(0)
		continue
	from math import sqrt as S
	k = (-1 + S(1 + 8 * d)) / 2
	k = int(k)
	if k * (k + 1) // 2 < d:
		k += 1
	sum = k * (k + 1) // 2
	while 1:
		sum = k * (k + 1) // 2
		if (sum - d) % 2 == 0:
			break
		k += 1
	print(k)


import math
tc = int(input())
while tc > 0:
	tc -= 1
	(a, b) = map(int, input().split())
	n = int(math.sqrt(2 * abs(a - b)))
	while ((a + b + n * (n + 1) // 2) % 2 != 0 or n * (n + 1) // 2) < abs(a - b):
		n += 1
	print(n)


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


MOD = 10 ** 9 + 7
INT_MAX = 10 ** 20 + 7

def INPUT():
	return list((int(i) for i in input().split()))

def LIST_1D_ARRAY(n):
	return [0 for _ in range(n)]

def LIST_2D_ARRAY(m, n):
	return [[0 for _ in range(n)] for _ in range(m)]

def power(a, x):
	res = 1
	while x > 0:
		if x & 1:
			res = res * a % MOD
		a = a * a % MOD
		x //= 2
	return res % MOD

def NCR_MOD(n, r):
	num = 1
	for i in range(n, n - r, -1):
		num = num * i % MOD
	for j in range(1, r + 1):
		num = num * power(j, MOD - 2) % MOD
	return num
import math as M

def calc(a, b):
	d = abs(a - b)
	if d == 0:
		return 0
	for x in range(1, 10 ** 5):
		s = x * (x + 1) // 2
		if s >= d:
			if s % 2 == d % 2:
				return x
for i in range(int(input())):
	(a, b) = INPUT()
	print(calc(a, b))


from math import ceil, floor, sqrt
for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	c = abs(a - b)
	steps = 0
	counter = 1
	steps = int(ceil((sqrt(1 + 8 * c) - 1) / 2))
	diff = c - steps * (steps + 1) // 2
	if diff < 0 and abs(diff) / 2 < steps + 1 and (abs(diff) % 2 != 0):
		steps += 1 if (steps + 1) % 2 == 1 else 2
	print(steps)


from bisect import bisect_left
a = [0]
for i in range(1, 10 ** 5):
	a.append(i * (i + 1) // 2)
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	i = bisect_left(a, abs(x - y))
	while a[i] % 2 != abs(x - y) % 2:
		i += 1
	print(i)


for _ in [0] * int(input()):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	i = int((2 * d) ** 0.5)
	s = i * (i + 1) // 2
	while (s ^ d) % 2 or s < d:
		i += 1
		s += i
	print(i)


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

def arr_sum(arr):
	arr.insert(0, 0)
	return list(accumulate(arr, lambda x, y: x + y))
from itertools import *
from sys import *
for i in range(int(input())):
	(a, b) = inp()
	if a == b:
		print(0)
	else:
		(ma, mi) = (max(a, b), min(a, b))
		(diff, i) = (ma - mi, 1)
		while diff > 0 or diff & 1:
			diff -= i
			i += 1
		print(i - 1)


n = int(input())
cusum = [0] * 50000
cusum[0] = 1
for i in range(1, len(cusum)):
	cusum[i] = cusum[i - 1] + i + 1
for i in range(n):
	(a, b) = list(map(int, input().split()))
	m = min(a, b)
	a -= m
	b -= m
	number = max(a, b)
	if number == 0:
		print(0)
		continue
	stop = False
	idx = -1
	if number >= cusum[12500]:
		idx = 12500
	elif number >= cusum[25000]:
		idx = 25000
	elif number >= cusum[37500]:
		idx = 37500
	elif number >= cusum[44715]:
		idx = 44715
	while not stop:
		idx += 1
		if cusum[idx] >= number and (cusum[idx] - number) % 2 == 0:
			stop = True
	print(idx + 1)


import sys
t = int(sys.stdin.readline())
ans_arr = []
for x in range(t):
	[a, b] = [int(i) for i in sys.stdin.readline().split()]
	if a == b:
		ans_arr.append(str(0))
	else:
		ax = a
		bx = b
		a = max(ax, bx)
		b = min(ax, bx)
		d = a - b
		for i in range(1, pow(10, 5) + 1):
			tmp = i * (i + 1) // 2
			if tmp - d >= 0 and (tmp - d) % 2 == 0 and ((d + tmp) % 2 == 0):
				ans_arr.append(str(i))
				break
print('\n'.join(ans_arr))


t = int(input())
for i in range(t):
	(x, y) = [int(i) for i in input().split()]
	diff = abs(x - y)
	counter = 0
	sm = 0
	while True:
		if sm >= diff:
			if (sm - diff) % 2 == 0:
				break
		counter += 1
		sm += counter
	print(counter)


import time
from math import sqrt

def is_good(cnt, df):
	sm = cnt * (cnt + 1) / 2
	return sm >= df and sm % 2 == df % 2
LOCAL = False
start_time = None
if LOCAL:
	start_time = time.time()
n = int(input())
for _ in range(n):
	(a, b) = list(map(lambda x: int(x), input().split(' ')))
	df = abs(b - a)
	if df == 0:
		print(0)
	else:
		good = False
		cnt = int((-1 + sqrt(1 + 8 * df)) / 2)
		sm = cnt * (cnt + 1) / 2
		while not (sm >= df and sm % 2 == df % 2):
			cnt += 1
			sm += cnt
		print(cnt)
if LOCAL:
	print('--- %s seconds ---' % (time.time() - start_time))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(diff, i) = (abs(a - b), 0)
	for i in range(0, 10 ** 6 + 1):
		summ = i * (i + 1) // 2
		if summ >= diff and diff & 1 == summ & 1:
			print(i)
			break


from sys import stdin, stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(a, b) = iia()
	d = abs(a - b)
	for i in range(100000):
		cur = i * (i + 1) // 2
		if cur >= d and d & 1 == cur & 1:
			print(i)
			break


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	x = math.ceil((-1 + math.sqrt(1 + 8 * abs(b - a))) / 2)
	diff = x * (x + 1) // 2 - abs(b - a)
	while diff % 2:
		x += 1
		diff = x * (x + 1) // 2 - abs(b - a)
		if x == 50:
			break
	print(x)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	if d == 0:
		print(0)
		continue
	delta = (1 / 4 + 2 * d) ** 0.5
	t = -1 / 2 + delta
	if int(t) == t:
		t = int(t)
	else:
		t = int(t + 1)
	while (t - 1) // 2 % 2 ^ d % 2 == 0:
		t += 1
	print(t)


import math
t = int(input())
for i in range(t):
	inp = input().split()
	(a, b) = (int(inp[0]), int(inp[1]))
	d = abs(a - b)
	nf = (math.sqrt(1 + 8 * d) - 1) / 2
	n = math.ceil(nf)
	if d % 2 != math.floor((n + 1) / 2) % 2:
		n = n + 1
	if d % 2 != math.floor((n + 1) / 2) % 2:
		n = n + 1
	print(n)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split(' '))
	d = abs(a - b)
	if d == 0:
		print(0)
	else:
		for i in range(4 - d % 2 * 2, 10 ** 5, 4):
			if i * (i + 1) // 2 >= d:
				if i * (i - 1) // 2 >= d:
					print(i - 1)
				else:
					print(i)
				break


import math
t = int(input())
for i in range(t):
	(a, b) = [int(i) for i in input().split()]
	k = abs(a - b)
	f = math.ceil((-1 + (1 + 8 * k) ** 0.5) / 2)
	if f != (-1 + (1 + 8 * k) ** 0.5) / 2:
		if k % 2 == 0:
			if f * (f + 1) // 2 % 2 == 0:
				print(f)
			elif (f + 2) * (f + 1) // 2 % 2 == 0:
				print(f + 1)
			elif (f + 2) * (f + 3) // 2 % 2 == 0:
				print(f + 2)
		elif f * (f + 1) // 2 % 2 == 1:
			print(f)
		elif (f + 2) * (f + 1) // 2 % 2 == 1:
			print(f + 1)
		elif (f + 2) * (f + 3) // 2 % 2 == 1:
			print(f + 2)
	else:
		print(f)


from sys import stdin, stdout
v = [0]
for i in range(1, 100000):
	v.append(v[-1] + i)
n = int(stdin.readline())
for i in range(n):
	(a, b) = map(int, stdin.readline().split())
	if a == b:
		stdout.write('0\n')
	else:
		c = 0
		for j in v:
			c += 1
			s = a + b + j
			if s % 2 == 0 and s >= a * 2 and (s >= b * 2):
				stdout.write(str(c - 1) + '\n')
				break


import sys
input = sys.stdin.readline
t = int(input())
NLIST = [N * (N + 1) // 2 for N in range(10 ** 5)]
import bisect
for test in range(t):
	(a, b) = map(int, input().split())
	x = abs(b - a)
	N = bisect.bisect_left(NLIST, x)
	while x % 2 != (N + 1) // 2 % 2:
		N += 1
	print(N)


from sys import stdin
t = int(stdin.readline())
while t:
	(a, b) = map(int, stdin.readline().split())
	c = 0
	d = abs(a - b)
	while d > 0 or d & 1:
		c += 1
		d -= c
	print(c)
	t -= 1


import sys
from math import ceil
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	sa = a - b
	k = 0
	cnt = 0
	while k < sa:
		cnt += 1
		k += cnt
	if sa == k:
		print(cnt)
	elif (k - sa) % 2 == 0:
		print(cnt)
	elif (k - sa + cnt + 1) % 2 == 0:
		print(cnt + 1)
	else:
		print(cnt + 2)


def f(n):
	k = ((1 + 8 * n) ** 0.5 - 1) / 2
	if int(k) == k:
		k = int(k)
	else:
		k = int(k) + 1
	if n % 2:
		if k % 4 in [1, 2]:
			return k
		else:
			while k % 4 not in [1, 2]:
				k += 1
			return k
	elif k % 4 not in [1, 2]:
		return k
	else:
		return k // 4 * 4 + 3
for i in ' ' * int(input()):
	(a, b) = map(int, input().split())
	print(f(abs(a - b)))


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	for i in range(4 * 10 ** 5):
		if (i * (i + 1) // 2 + a + b) % 2 == 0:
			if i * (i + 1) // 2 >= abs(a - b):
				print(i)
				break


import sys
import math
import heapq
import collections

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

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

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

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

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

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

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(a, b) = inputnums()
	c = abs(a - b)
	d = 0
	sm = 0
	while sm < c:
		d += 1
		sm += d
	if sm % 2 != c % 2:
		d += 1
		sm += d
	if sm % 2 != c % 2:
		d += 1
		sm += d
	print(d)


import sys
from math import gcd
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from bisect import bisect_right
from bisect import bisect_left
from sys import stdin, stdout
from collections import defaultdict, deque
from math import log2, ceil, floor
inp = lambda : int(input())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, input().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
Judge = 0
if Judge:
	sys.stdin = open('input.in', 'r')

def cal(s):
	l = 1
	r = int(s / 2) + 1
	while l <= r:
		mid = int((l + r) / 2)
		sum = int(mid * (mid + 1) / 2)
		if sum == s:
			return mid
		elif sum > s:
			r = mid - 1
		else:
			l = mid + 1
	return -1

def summ(n):
	s = n * (n + 1) // 2
	return s
for _ in range(inp()):
	(a, b) = mulip()
	if a == b:
		print(0)
	else:
		d = abs(a - b)
		for i in range(pow(10, 5)):
			s = i * (i + 1) // 2
			if s >= d and (s - d) % 2 == 0:
				print(i)
				break


t = int(input())

def minimum(a, b):
	if a == b:
		return 0
	(Found, n) = (False, 1)
	while not Found:
		temp = a + n * (n + 1) // 2
		if temp < b:
			n += 1
		elif (temp - b) % 2 == 0:
			Found = True
		else:
			n += 1
	return n
for i in range(t):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	print(minimum(min(a, b), max(a, b)))


import random

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

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = 0
	k = 0
	while 1:
		if (a + b + c) % 2 == 0 and (a + b + c) // 2 >= max(a, b):
			break
		k += 1
		c += k
	print(k)


from math import *

def solve(x, d):
	tot = x * (x + 1) // 2
	if tot < d:
		return False
	elif (tot - d) % 2 == 0:
		return True
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	x = 1
	if d == 0:
		print(0)
		continue
	while not solve(x, d):
		x += 1
	print(x)


def possible(diff, x):
	if x * (x + 1) // 2 >= diff and diff % 2 == x * (x + 1) // 2 % 2:
		return 1
	return 0
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if 1:
		diff = abs(b - a)
		x = 0
		while possible(diff, x) == 0:
			x += 1
		print(x)


from collections import deque
import sys
import math
q = int(input())
for _ in range(q):
	(a, b) = map(int, input().split())
	diff = max(a, b) - min(a, b)
	a = math.floor(math.sqrt(diff))
	while diff > a * (a + 1) // 2:
		a += 1
	if (a * (a + 1) // 2 - diff) % 2 == 0:
		print(a)
	elif ((a + 1) * (a + 2) // 2 - diff) % 2 == 0:
		print(a + 1)
	else:
		print(a + 2)


def check(x, sum):
	tmp = int(x * (x + 1) / 2)
	if tmp < sum:
		return False
	return tmp % 2 == sum % 2
n = int(input())
for it in range(n):
	(a, b) = map(int, input().split())
	sum = abs(a - b)
	if sum == 0:
		print(0)
		continue
	x = 1
	while not check(x, sum):
		x += 1
	print(x)


def bs(v):
	(l, r) = (-1, 10 ** 5)
	while r - l > 1:
		m = (r + l) // 2
		if m * (m + 1) // 2 < v:
			l = m
		else:
			r = m
	return r

def solve(x, y):
	if x > y:
		(x, y) = (y, x)
	d = y - x
	k = bs(d)
	u = k * (k + 1) // 2 - d
	while u % 2 != 0 or u // 2 > k * (k + 1) // 2:
		k += 1
		u = k * (k + 1) // 2 - d
	return k
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	res = solve(a, b)
	print(res)


from sys import stdin, stdout
t = int(input())
for i in range(t):
	(a, b) = stdin.readline().split()
	a = int(a)
	b = int(b)
	count = 0
	sum1 = 0
	diff = abs(a - b)
	while sum1 < diff:
		count += 1
		sum1 += count
	while (a + b + sum1) % 2 != 0:
		count += 1
		sum1 += count
	print(count)


l = []
i = 1
count = 0
while 1:
	count += i
	l.append(count)
	i += 1
	if count > 1000000005:
		break

def find(n):
	low = 0
	high = 44720
	index = -1
	while 1:
		mid = (low + high) // 2
		if low > high:
			index = high
			break
		if l[mid] == n:
			index = mid
			break
		elif l[mid] < n:
			low = mid + 1
		else:
			high = mid - 1
	return index
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	dif = abs(n - m)
	if dif == 0:
		print(0)
	else:
		temp = find(dif)
		while 1:
			temp2 = temp * (temp + 1) // 2
			if temp2 < dif:
				temp += 1
			elif (temp2 + n + m) % 2 == 0:
				print(temp)
				break
			else:
				temp += 1


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
let = '@abcdefghijklmnopqrstuvwxyz'
for _ in range(ii()):
	(a, b) = f()
	sm = 0
	for i in range(10 ** 5 + 1):
		sm += i
		if (a + b + sm) % 2 == 0 and (a + b + sm) // 2 >= max(a, b):
			print(i)
			break


import math as m
t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	x = max(a, b)
	d = 1 - 4 * (2 * (a + b) - 4 * x)
	d = pow(d, 0.5)
	ro1 = (-1 + d) / 2
	ro2 = (-1 - d) / 2
	ma = max(ro1, ro2)
	res = int(m.ceil(ma))
	su = res * (res + 1)
	su = su // 2
	su += a + b
	if su % 2 != 0 and res % 2 == 0:
		res += 1
	elif su % 2 != 0:
		res += 2
	print(res)


l = []
for i in range(1, 100005):
	l.append(i * (i + 1) // 2)
for a0 in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a == b:
		print(0)
		continue
	for i in range(0, 100004):
		if l[i] >= b - a and (l[i] + a + b) % 2 == 0:
			print(i + 1)
			break


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	d = max(a, b) - min(a, b)
	n = 0
	while True:
		s = n * (n + 1) // 2
		if s >= d and (s - d) % 2 == 0:
			break
		n += 1
	print(n)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(n, m) = (min(n, m), max(n, m))
	(l, r) = (-1, 100000)
	while r - l > 1:
		m1 = (l + r) // 2
		if m1 * (m1 + 1) // 2 >= m - n:
			r = m1
		else:
			l = m1
	while (r * (r + 1) // 2 % 2 + m - n) % 2 == 1:
		r += 1
	print(r)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	k = -abs(a - b)
	i = 0
	while k < 0 or k % 2 != 0:
		k -= (i - 1) * i // 2
		k += i * (i + 1) // 2
		i += 1
	if i == 0:
		print(i)
	else:
		print(i - 1)


l = []
for i in range(10 ** 5 + 1):
	l.append(i * (i + 1) // 2)
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	else:
		d = abs(a - b)
		c = 0
		for i in range(len(l)):
			(u, v) = (l[i] % 2, d % 2)
			if l[i] >= d and u == v:
				print(c)
				break
			else:
				c += 1
			i += 1


from math import sqrt

def sump(n):
	return n * (n + 1) // 2
for _ in range(int(input())):
	(a, b) = sorted(map(int, input().split()))
	p = int((sqrt(1 + 8 * (b - a)) - 1) // 2)
	while True:
		k = sump(p) - (b - a)
		if k >= 0 and k % 2 == 0:
			print(p)
			break
		p += 1


import os
import sys
import math
from io import BytesIO, IOBase
input = sys.stdin.readline

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

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

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

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

def dijkstra(start, distance, path, n):
	visited = [False for _ in range(n)]
	distance[start] = 0
	for i in range(n):
		v = -1
		for j in range(n):
			if not visited[v] and (v == -1 or distance[j] < distance[v]):
				v = j
		if distance[v] == math.inf:
			break
		visited[v] = True
		for edge in adj[v]:
			destination = edge[0]
			weight = edge[1]
			if distance[v] + weight < distance[destination]:
				distance[destination] = distance[v] + weight
				path[destination] = v

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

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

def ncr(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def npr(n, r):
	return math.factorial(n) // math.factorial(n - r)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 1
	while x * x <= n:
		if n % x == 0:
			if n // x == x:
				factors.append(x)
			else:
				factors.append(x)
				factors.append(n // x)
		x += 1
	return factors

def main():
	try:
		for _ in range(inp()):
			(a, b) = invr()
			if a == b:
				print('0')
				continue
			mx = max(a, b)
			mn = min(a, b)
			diff = mx - mn
			(l, r) = (1, 10 ** 9)
			while l <= r:
				m = (l + r) // 2
				val = m * (m + 1) // 2
				if val < diff:
					l = m + 1
				else:
					r = m - 1
			while l * (l + 1) // 2 - diff & 1:
				l += 1
			print(l)
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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


def delta(x):
	(l, r) = (-1, 100000)
	while l + 1 < r:
		mid = l + r >> 1
		tot = mid * (mid + 1) // 2
		if tot < x:
			l = mid
		else:
			r = mid
	if (r * (r + 1) // 2 - x) % 2 != 0:
		return r + 1 + r % 2
	else:
		return r
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	print(delta(abs(a - b)))


from math import *
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	x = ceil((-1 + (1 + 8 * (b - a)) ** 0.5) / 2)
	if a % 2 == b % 2:
		while x % 4 not in [0, 3]:
			x += 1
	else:
		while x % 4 not in [1, 2]:
			x += 1
	print(x)


def solve(a, b):
	diff = abs(a - b)
	n = float('inf')
	low = 0
	high = 10 ** 15
	while low <= high:
		mid = low + (high - low) // 2
		if mid * (mid + 1) >= 2 * diff:
			n = mid
			high = mid - 1
		else:
			low = mid + 1
	if (a + b) % 2 == 0:
		while n * (n + 1) // 2 % 2 != 0:
			n += 1
	else:
		while n * (n + 1) // 2 % 2 == 0:
			n += 1
	print(n)

def main():
	t = int(input())
	for i in range(t):
		(a, b) = map(int, input().split())
		solve(a, b)
main()


import sys, os, io

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

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

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

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

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

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

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	k = 0
	z = []
	for i in range(1, 100001):
		z.append(k)
		k += i
	for _ in range(ri()):
		(a, b) = ria()
		for i in range(len(z)):
			k = z[i]
			if (k + b - a) % 2 == 0:
				x = (k + (b - a)) // 2
				y = k - x
				if x >= 0 and y >= 0:
					print(i)
					break
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

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

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

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

class FastWriter(io.IOBase):

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

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

class FastStdin(io.IOBase):

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

class FastStdout(io.IOBase):

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


import math
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	diff = abs(b - a)
	sum1 = 0
	k = 1
	count = 0
	a = 1
	b = 1
	c = -(diff * 2)
	delta = b * b - 4 * a * c
	if delta >= 0:
		x1 = -b + math.floor(math.sqrt(delta))
		x1 = math.floor(x1 / (2 * a))
	count = x1
	k = x1
	sum1 = k * (k + 1)
	sum1 = sum1 / 2
	k = k + 1
	while sum1 < diff:
		sum1 += k
		count += 1
		k += 1
	if sum1 == diff or (sum1 % 2 == 0 and diff % 2 == 0) or (sum1 % 2 == 1 and diff % 2 == 1):
		print(count)
		continue
	if diff % 2 == 0:
		while sum1 % 2 != 0:
			sum1 += k
			count += 1
			k += 1
	else:
		while sum1 % 2 != 1:
			sum1 += k
			count += 1
			k += 1
	print(count)


import sys, math, queue, collections
MOD = 10 ** 9 + 7
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	ans = 0
	while a < b or (b - a) % 2 != 0:
		a += ans + 1
		ans += 1
	print(ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	for n in range(0, 1000000):
		x = n * (n + 1) // 2
		if x >= d and d & 1 == x & 1:
			print(n)
			break


for _ in [0] * int(input()):
	(a, b) = sorted([int(x) for x in input().split()])
	diff = abs(a - b)
	ans = 0
	sums = 0
	while sums < diff or sums % 2 != diff % 2:
		ans += 1
		sums += ans
	print(ans)


for u in range(int(input())):
	(x, y) = map(int, input().split())
	ka = abs(x - y)
	c = 0
	for i in range(1000001):
		if ka <= i * (i + 1) // 2 and (i + 1) // 2 % 2 == ka % 2:
			c = i
			break
	print(c)


t = int(input())
for i in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	dif = abs(a - b)
	n = int((2 * dif) ** 0.5)
	for j in range(5):
		S = int(n * (n + 1) / 2)
		if S >= dif and (S - dif) % 2 == 0:
			print(n)
			break
		n += 1


q = int(input())
while q:
	(a, b) = map(int, input().split())
	sum_ = a + b
	i = 0
	while (i * (i + 1) // 2 + sum_) % 2 != 0 or i * (i + 1) // 2 + sum_ < 2 * max(a, b):
		i += 1
	print(i)
	q -= 1


from math import ceil
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	n = ceil((-1 + (1 + 8 * d) ** 0.5) / 2)
	while (n * (n + 1) // 2 - d) % 2:
		n += 1
	print(n)


from math import *
for _ in range(int(input())):
	(a, b) = [int(i) for i in input().split()]
	diff = abs(a - b)
	x = int(ceil((sqrt(1 + 8 * diff) - 1) / 2))
	while (diff - x * (x + 1) / 2) % 2 == 1:
		x += 1
	print(x)


import math
q = int(input())
for _ in range(q):
	s = input().split()
	x = min(int(s[0]), int(s[1]))
	y = max(int(s[0]), int(s[1]))
	n = int(math.sqrt(2 * (y - x))) - 1
	if x == y:
		print(0)
	else:
		while 1 > 0:
			x1 = 2 * (y - x) + n * (n + 1)
			x2 = n * (n + 1) - 2 * (y - x)
			if x1 % 4 == 0 and x2 % 4 == 0 and (x1 * x2 >= 0):
				print(n)
				break
			n += 1


import math
tu = int(input())
for tu in range(tu):
	fg = input().split(' ')
	asp = int(fg[1])
	bsp = int(fg[0])
	a = min(asp, bsp)
	b = max(asp, bsp)
	d = b - a
	k = math.ceil((math.sqrt(1 + 8 * d) - 1) / 2)
	for h in range(3):
		if (d + k * (k + 1) // 2) % 2 == 0:
			print(k)
			break
		k += 1


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	x = abs(a - b)
	n = 0
	while n * (n + 1) // 2 < x or (n * (n + 1) // 2 - x) % 2 != 0:
		n += 1
	print(n)


ls = []
prev = 0
for i in range(int(10 ** 5) + 1):
	prev += i
	ls.append(prev)
t = int(input())
while t:
	(a, b) = map(int, input().split())
	c = min(a, b)
	d = max(a, b)
	ans = 10 ** 9 + 1
	for i in range(int(10 ** 5) + 1):
		if c + ls[i] >= d:
			if (c + ls[i] - d) % 2 == 0:
				ans = min(ans, i)
	print(ans)
	t -= 1


for t in range(int(input())):
	(a, b) = map(int, input().split())
	if b < a:
		(a, b) = (b, a)
	for i in range(100000):
		sa = i * (i + 1) // 2 + b - a
		if sa % 2 == 0:
			sa //= 2
			sb = sa - b + a
			if sb >= 0 and sa >= 0:
				print(i)
				break


def cal(n, diff):
	delta = int(n * (n + 1) // 2)
	if (delta - diff) % 2 == 0:
		return True
	else:
		return False

def solve():
	(n, m) = [int(x) for x in input().split()]
	diff = abs(n - m)
	delta = abs(n - m) * 2
	left = 0
	right = 1000000000
	ans = float('inf')
	while left <= right:
		mid = int((left + right) // 2)
		if mid * (mid + 1) >= delta:
			if cal(mid, diff):
				ans = min(ans, mid)
			elif cal(mid + 1, diff):
				ans = min(mid + 1, ans)
			elif cal(mid + 2, diff):
				ans = min(mid + 2, ans)
			right = mid - 1
		else:
			left = mid + 1
	print(ans)
t = int(input())
for test in range(t):
	solve()


t = int(input())
while t:
	(a, b) = map(int, input().split())
	dif = -abs(a - b)
	k = 1
	t = t - 1
	while dif < 0:
		dif += k
		k = k + 1
	if dif % 2 == 0:
		print(k - 1)
	else:
		dif += k
		if dif % 2 == 0:
			print(k)
		else:
			print(k + 1)


t = int(input())
import math
for i in range(t):
	(a, b) = map(int, input().split())
	w = int(math.fabs(a - b))
	if a == b:
		print(0)
	elif w % 2 == 0:
		c = 0
		for j in range(1, 1000000):
			if c >= w and c % 2 == 0:
				break
			else:
				c += j
		print(j - 1)
	elif w % 2 != 0:
		c = 0
		for j in range(1, 1000000):
			if c >= w and c % 2 != 0:
				break
			else:
				c += j
		print(j - 1)


import sys
input = sys.stdin.readline
from collections import Counter
orda = ord('a')
t = int(input())
for _ in range(t):
	(a, b) = [int(item) for item in input().split()]
	diff = abs(a - b)
	l = -1
	r = 10 ** 9
	while r - l > 1:
		mid = (l + r) // 2
		total = mid * (mid + 1) // 2
		if total > diff:
			r = mid
		else:
			l = mid
	val = l * (l + 1) // 2
	for i in range(1, 10):
		if val >= diff and diff % 2 == val % 2:
			print(l + i - 1)
			break
		val += l + i


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):
		(a, b) = map(int, input().split())
		if a == b:
			print(0)
			continue

		def check(x, diff):
			temp = x * (x + 1) // 2
			if temp < diff:
				return False
			return (temp + diff) % 2 == 0
		ans = 0
		while not check(ans, abs(a - b)):
			ans += 1
		print(ans)
main()


import sys
reader = (map(int, s.split()) for s in sys.stdin)
(t,) = next(reader)
for _ in range(t):
	(a, b) = next(reader)
	if a == b:
		print(0)
		continue
	d = abs(a - b)
	n = int((2 * d) ** 0.5)
	s = n * (n + 1) // 2
	if s < d:
		n += 1
		s += n
	while s % 2 != d % 2:
		n += 1
		s += n
	print(n)


from math import *
t = int(input())
for i in range(t):
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	d = abs(a - b)
	n = int(sqrt(2 * d))
	if n * (n + 1) // 2 == d:
		ans = n
	elif (n + 1) * (n + 2) // 2 == d:
		ans = n + 1
	elif (n - 1) * n // 2 == d:
		ans = n - 1
	elif n * (n + 1) // 2 > d and n * (n - 1) // 2 < d:
		if (n * (n + 1) // 2 - d) % 2 == 0:
			ans = n
		elif ((n + 1) * (n + 2) // 2 - d) % 2 == 0:
			ans = n + 1
		elif ((n + 2) * (n + 3) // 2 - d) % 2 == 0:
			ans = n + 2
		else:
			ans = n + 3
	elif (n + 1) * (n + 2) // 2 > d and n * (n + 1) // 2 < d:
		if ((n + 1) * (n + 2) // 2 - d) % 2 == 0:
			ans = n + 1
		elif ((n + 2) * (n + 3) // 2 - d) % 2 == 0:
			ans = n + 2
		elif ((n + 3) * (n + 4) // 2 - d) % 2 == 0:
			ans = n + 3
		else:
			ans = n + 4
	print(ans)


from math import sqrt, ceil
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = abs(x - y)
	z = ceil((-1 + sqrt(1 + 8 * a)) / 2)
	while (z * (z + 1) // 2 + y + x) % 2 != 0:
		z += 1
	print(z)


arr = [0] * 100001
for i in range(1, 100001):
	arr[i] = arr[i - 1] + i
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	if d == 0:
		print(0)
	else:
		for i in range(1, 100001):
			if arr[i] >= d and (arr[i] - d) % 2 == 0:
				print(i)
				break


from collections import deque

def f(a, b):
	n = abs(a - b)
	if n == 0:
		return 0

	def t(n):
		return n * (n + 1) // 2
	k = 1
	while t(k) <= n:
		if t(k + 1) > n:
			break
		k += 1
	if n == t(k):
		return k
	if k % 2 == 1:
		if (n - t(k)) % 2 == 1:
			return k + 2
		else:
			return k + 1
	elif (n - t(k)) % 2 == 1:
		return k + 1
	else:
		return k + 3
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	print(f(a, b))


import collections
for t in range(int(input())):
	(a, b) = list(map(int, input().split()))
	(a, b) = (b, a) if b > a else (a, b)
	if not ((1 + 8 * (a - b)) ** 0.5 - 1) % 2 and ((1 + 8 * (a - b)) ** 0.5 - 1) // 2 >= 0:
		ans = ((1 + 8 * (a - b)) ** 0.5 - 1) // 2
		print(int(ans))
	else:
		n1 = int(((1 + 8 * (a - b)) ** 0.5 - 1) // 2) + 1
		while n1 * (n1 + 1) // 2 % 2 != (a - b) % 2:
			n1 += 1
		print(n1)


import sys

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

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

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

def compute(start, end):
	if start == end:
		return 0
	t = abs(end)
	step = 0
	curr = start
	while True:
		curr += step + 1
		if curr >= t:
			if (curr - t) % 2 == 0:
				return step + 1
		step += 1
T = int(input())
while T:
	(x, y) = get_ints()
	start = min(x, y)
	end = max(x, y)
	ans = compute(start, end)
	print(ans)
	T -= 1


for t in range(int(input())):
	(a, b) = map(int, input().split())
	d = max(a, b) - min(a, b)
	i = 0
	while d % 2 or d > 0:
		i += 1
		d -= i
	print(i)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = abs(a - b)
	y = 0
	j = 1
	count = 0
	while y + j <= x:
		y += j
		j += 1
		count += 1
	z = x - y
	if z == 0:
		print(count)
		continue
	if (z - j) % 2 == 0:
		count += 1
	elif j % 2 == 0:
		count += 2
	else:
		count += 3
	print(count)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	else:
		i = 1
		count = 0
		su = a + b
		while 1:
			s = i * (i + 1) // 2
			s1 = su + s
			count += 1
			if s1 % 2 == 0:
				d1 = s1 // 2
				d2 = s1 // 2
				if a <= d1 and b <= d2:
					print(count)
					break
			i += 1


from time import *
x = int(input())
for _ in range(x):
	(a, b) = sorted(map(int, input().split()))
	diff = b - a
	(n, i) = (0, 0)
	while True:
		if n >= diff and (n - diff) % 2 == 0:
			print(i)
			break
		i += 1
		n += i


n = int(input())
for _ in range(n):
	line = input().split()
	(a, b) = tuple(map(lambda x: int(x), line))
	if a > b:
		diff = a - b
	elif a < b:
		diff = b - a
	else:
		print('0')
		continue
	t = 1
	while t * (t + 1) < 2 * diff:
		t *= 2
	(head, tail) = (t // 2, t)
	while tail - head >= 2:
		mid = (head + tail) // 2
		if mid * (mid + 1) < 2 * diff:
			head = mid
		else:
			tail = mid
	(mod_diff, mod_tail) = (diff % 2, (tail - 1) % 4 + 1)
	if mod_diff == 1 and mod_tail >= 3:
		tail = tail + 5 - mod_tail
	elif mod_diff == 0 and mod_tail < 3:
		tail = tail + 3 - mod_tail
	print(tail)


from math import ceil, sqrt
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	e = ceil((-1 + sqrt(1 + 8 * d)) / 2)
	if d % 2 == 0:
		while True:
			if e % 4 == 0 or e % 4 == 3:
				break
			e += 1
	else:
		while True:
			if e % 4 == 1 or e % 4 == 2:
				break
			e += 1
	print(e)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	cnt = 0
	if a > b:
		(a, b) = (b, a)
	while a < b:
		cnt += 1
		a += cnt
	while (a - b) % 2 == True:
		cnt += 1
		a += cnt
	print(cnt)


t = int(input())
for _ in range(t):
	(a, b) = [int(p) for p in input().split()]
	if a > b:
		temp = a
		a = b
		b = temp
	d = b - a
	for i in range(int(10 ** 5) + 7):
		x = i * (i + 1) / 4 + d / 2
		if int(x) != x:
			continue
		y = x - d
		if x >= 0 and y >= 0 and (a + x == b + y):
			print(i)
			break


import sys, math, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def find_gt(a, x):
	i = bisect_right(a, x)
	if i != len(a):
		return a[i]
	raise ValueError
n = I()
l = [0]
for i in range(1, int(math.sqrt(10 ** 10)) + 1):
	l.append(l[i - 1] + i)
for _ in range(n):
	(a, b) = M()
	d = abs(a - b)
	i = bisect.bisect_left(l, d)
	sum = l[i]
	i += 1
	while True:
		if sum % 2 == (a + b) % 2 and sum >= d:
			print(i - 1)
			break
		sum += i
		i += 1


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	m = int((abs(b - a) * 2) ** 0.5)
	for i in range(10):
		q = m * (m + 1) // 2
		if q >= abs(b - a) and (q - abs(b - a)) % 2 == 0:
			print(m)
			break
		m += 1


import sys
input = sys.stdin.readline
import bisect
from math import ceil
t = int(input())
p = int(100000.0)
lis = [1] * p
for i in range(1, p):
	lis[i] = lis[i - 1] + i + 1
while t:
	t -= 1
	(a, b) = map(int, input().split())
	(a, b) = (a, b) if a < b else (b, a)
	x = b - a
	if x:
		index = bisect.bisect_left(lis, x)
		p = (lis[index] - x) / 2
		while int(p) != ceil(p):
			index += 1
			p = (lis[index] - x) / 2
		print(index + 1)
	else:
		print(0)


import sys
input = sys.stdin.readline

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

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

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

def getStr():
	return input().strip()

def listStr():
	return list(input().strip())
import collections as col
import math, itertools

def solve():
	(A, B) = getInts()
	if A == B:
		return 0
	diff = abs(A - B)
	left = 0
	right = 10 ** 6
	while right - left > 1:
		mid = (left + right) // 2
		if mid * (mid + 1) // 2 == diff:
			right = mid
			break
		if mid * (mid + 1) // 2 > diff:
			right = mid
		else:
			left = mid
	while right * (right + 1) // 2 % 2 != diff % 2:
		right += 1
	return right
for _ in range(getInt()):
	print(solve())


e = int(input())
for i in range(e):
	(a, b) = map(int, input().split())
	ans = 0
	s = 0
	while s * (s + 1) // 2 < max(a, b) - min(a, b) or s * (s + 1) // 2 % 2 != (max(a, b) - min(a, b)) % 2:
		s += 1
	print(s)


import math
for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	if a == b:
		print(0)
		continue
	flag = True
	sum = a + b
	mi = max(a, b) - min(a, b)
	cnt = int(math.sqrt(mi))
	while flag:
		if (sum + cnt * (cnt + 1) / 2) % 2 == 0 and cnt * (cnt + 1) / 2 >= mi:
			print(cnt)
			flag = False
		cnt += 1


t = int(input())
for i in range(t):
	(a, b) = input().strip().split(' ')
	(a, b) = [int(a), int(b)]
	c = abs(a - b)
	flag = 0
	i = 0
	sum = 0
	if c == 0:
		print(0)
	else:
		while True:
			i += 1
			sum += i
			if sum >= c and (sum - c) % 2 == 0:
				print(i)
				break


ar = []
from bisect import bisect_left as lfind
for i in range(10 ** 5):
	ar.append(i * (i - 1) // 2)
for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	n = abs(a - b)
	if n == 0:
		print(0)
		continue
	pos = lfind(ar, n)
	if (ar[pos] - n) % 2 == 0:
		print(pos - 1)
	elif (ar[pos + 1] - n) % 2 == 0:
		print(pos)
	else:
		print(pos + 1)


t = int(input())
for _ in range(t):
	(c, d) = [int(x) for x in input().split()]
	a = max(c, d)
	b = min(c, d)
	d = a - b
	n = (-1 + (1 + 8 * d) ** 0.5) / 2
	if n > int(n):
		n = int(n) + 1
	else:
		n = int(n)
	newB = b + (1 + n) * n // 2
	while (newB - a) % 2 == 1:
		n += 1
		newB += n
	print(n)


t = int(input())
for _ in range(t):
	(a, b) = (int(i) for i in input().split())
	if a == b:
		print(0)
		continue
	l = 1
	h = 10 ** 9
	while l < h:
		m = (l + h) // 2
		if m * (m + 1) // 2 >= abs(a - b):
			h = m
		else:
			l = m + 1
	if abs(a - b) % 2 == 0:
		i = h
		for i in range(h, 10 ** 9):
			if i * (i + 1) // 2 & 1 == 0:
				break
		print(i)
	else:
		i = h
		for i in range(h, 10 ** 9):
			if i * (i + 1) // 2 & 1 != 0:
				break
		print(i)


def f():
	(a, b) = [int(s) for s in input().split()]
	if a < b:
		(a, b) = (b, a)
	need = a - b
	if need == 0:
		return 0
	n = int((2 * need) ** 0.5)
	if n * (n + 1) >= 2 * need:
		x = n
	else:
		x = n + 1
	while (x * (x + 1) // 2 - need) % 2:
		x += 1
	return x
t = int(input())
for i in range(t):
	print(f())


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		print('0')
		continue
	l = 1
	s = a + b
	need = max(a, b) * 2
	r = 1000000
	while l < r:
		m = (l + r) // 2
		if s + m * (m + 1) // 2 < need:
			l = m + 1
		else:
			r = m
	s += l * (l - 1) // 2
	while l > 0:
		s = s + l
		if s >= need and s % 2 == 0:
			print(l)
			break
		else:
			l += 1


import math

def check(x):
	tmp = int(x * (x + 1) / 2)
	if tmp < sum:
		return False
	if tmp % 2 == sum % 2:
		return True
	return False
n = int(input())
for it in range(n):
	(a, b) = map(int, input().split())
	sum = max(a, b) - min(a, b)
	if sum == 0:
		print(0)
		continue
	x = int(1 / 2 * math.sqrt(8 * sum + 1) - 1) - 1
	while not check(x):
		x += 1
	print(x)


def gt(a, b):
	d = b - a
	if d == 0:
		return 0
	(x, i) = (1, 1)
	while x < d or x % 2 != d % 2:
		i += 1
		x = i * (i + 1) // 2
	return i
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	r = gt(a, b)
	print(r)


import math
t = int(input())
for _ in range(t):
	c = list(map(int, input().split()))
	(a, b) = (max(c), min(c))
	if a == b:
		print(0)
	else:
		p = 2 * (a - b)
		k = (-1 + (1 + 4 * p) ** 0.5) / 2
		k = math.ceil(k)
		for i in range(max(1, k - 10), k + 10):
			l = i * (i + 1) // 2
			if l >= a - b:
				if l % 2 == (a - b) % 2:
					print(i)
					break


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	sm = 0
	c = 0
	while sm < a - b:
		c += 1
		sm += c
	if (b + sm - a) % 2 == 0:
		print(c)
	elif (c + 1) % 2 == 0:
		print(c + 2)
	else:
		print(c + 1)


from math import sqrt, floor
t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	p = max(a, b)
	ans = 0
	while a != b:
		s = float(2 * p - (a + b))
		q = (-1 + sqrt(8 * s + 1)) / 2
		if q - floor(q) == 0:
			ans = int(q)
			a = b
		p += 1
	print(ans)


q = int(input())
for rere in range(q):
	(a, b) = map(int, input().split())
	d = abs(b - a)
	i = 0
	while i * (i + 1) // 2 < d:
		i += 1
	if d % 2 == i * (i + 1) // 2 % 2:
		print(i)
	else:
		a = i * (i + 1) // 2 % 2
		while i * (i + 1) // 2 % 2 == a:
			i += 1
		print(i)


n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split(' ')))
	d = abs(a - b)
	s = 0
	if d == 0:
		print(0)
		continue
	for i in range(1, int(1000000000.0)):
		s += i
		if d <= s and (i - 1) // 2 % 2 != d % 2:
			print(i)
			break


import sys
ip = lambda : sys.stdin.readline().rstrip()
for _ in range(int(ip())):
	(a, b) = map(int, ip().split())
	diff = abs(a - b)
	if diff == 0:
		print(0)
		continue
	ans = 1
	while True:
		v = ans * (ans + 1) // 2
		if v >= diff and v % 2 == diff % 2:
			break
		else:
			ans += 1
	print(ans)


def calc(d):
	return int((1 + 4 * d) ** 0.5 // 2)
t = int(input())
for nt in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	d = a - b
	if d % 2 == 0:
		i = calc(2 * d)
		while True:
			if (i ** 2 + i) % 4 == 0 and i ** 2 + i - 2 * d >= 0:
				print(i)
				break
			i += 1
	else:
		i = calc(2 * d)
		while True:
			if (i ** 2 + i) % 4 == 2 and i ** 2 + i - 2 * d >= 0:
				print(i)
				break
			i += 1


t = int(input())
while t > 0:
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	if a > b:
		diff = a - b
	else:
		diff = b - a
	i = 1
	s = 0
	c = 0
	flag = False
	if diff == 0:
		print(0)
	else:
		while flag == False:
			s = s + i
			i = i + 1
			c = c + 1
			if s >= diff:
				if (s - diff) % 2 == 0:
					flag = True
		print(c)
	t = t - 1


tests = int(input())
for te in range(tests):
	(a, b) = list(map(int, input().split()))
	diff = abs(a - b)
	for i in range(10 ** 5):
		c = i * (i + 1) // 2
		if c >= diff and c % 2 == diff % 2:
			print(i)
			break


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	if d == 0:
		print(0)
	else:
		for i in range(1, d + 1):
			if (i ** 2 + i) / 2 >= d:
				break
		for j in range(i, 100000000):
			if (j * (j + 1) / 2 - d) % 2 == 0:
				print(j)
				break


import math
for _ in range(int(input())):
	(a, b) = sorted(map(int, input().split()))
	n = int(math.sqrt(b - a))
	while True:
		z = n * (n + 1) // 2
		x = b - a + z
		y = a + z - b
		if x >= 0 and y >= 0 and (x % 2 == 0) and (y % 2 == 0) and (a + x // 2 == b + y // 2):
			print(n)
			break
		n += 1


from collections import Counter
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	else:
		diff = abs(b - a)
		b = diff
		nearly = (-1 + pow(1 + 8 * diff, 0.5)) / 2
		if nearly == int(nearly):
			print(int(nearly))
			continue
		hey = int(nearly) + 1
		diff2 = hey * (hey + 1) // 2 - diff
		if diff2 % 2 == 0:
			print(hey)
		else:
			ans = hey + 1
			if (ans * (ans + 1) // 2 - diff) % 2 == 0:
				print(ans)
			else:
				print(ans + 1)


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
		continue
	x = max(a, b)
	y = min(a, b)
	ans = 0
	while 1:
		ans += 1
		if ans * (ans + 1) // 2 >= x - y and ans * (ans + 1) // 2 % 2 == (x - y) % 2:
			break
	print(ans)


def par(i):
	return i % 4 in (1, 2)

def calc(d):
	(l, r) = (0, 10 ** 9)
	while r - l > 1:
		mid = (l + r) // 2
		if (1 + mid) * mid // 2 > d:
			r = mid
		else:
			l = mid
	for i in range(max(0, l - 8), l + 8):
		if (1 + i) * i // 2 >= d and par(i) == d % 2:
			return i
	return None
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	print(calc(abs(a - b)))


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

def sin():
	return input()

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

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

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

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

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

def main():
	for _ in range(iin()):
		(a, b) = ain()
		if a > b:
			(a, b) = (b, a)
		n = 0
		while 1:
			t = n * (n + 1) + 2 * (a + b)
			if t % 4 == 0:
				if t // 4 >= b:
					break
			n += 1
		print(n)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for testcase in range(t):
	integers = [int(x) for x in input().split()]
	(a, b) = (integers[0], integers[1])
	c = abs(b - a)
	sq = (8 * c + 1) ** (1 / 2)
	n = int((sq - 1) // 2)
	ans = 0
	triangular = n * (n + 1) // 2
	while triangular < c or (triangular - c) % 2 != 0:
		n += 1
		triangular = n * (n + 1) // 2
	print(int(n))


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	diff = abs(a - b)
	ans = -1
	for i in range(0, 100001):
		if diff <= i * (i + 1) // 2 and diff % 2 == (i + 1) // 2 % 2:
			ans = i
			break
	print(ans)


t = int(input())
for query in range(t):
	(a, b) = list(map(int, input().split()))
	c = abs(a - b)
	left = -1
	right = 10 ** 9
	while right - left > 1:
		mid = (left + right) // 2
		if mid * (mid + 1) // 2 >= c:
			right = mid
		else:
			left = mid
	while right * (right + 1) // 2 % 2 != c % 2:
		right += 1
	print(right)


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10000
MOD = 10 ** 9 + 7
spf = [i for i in range(MAXN)]

def sieve():
	for i in range(2, MAXN, 2):
		spf[i] = 2
	for i in range(3, int(MAXN ** 0.5) + 1):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def fib(n, m):
	if n == 0:
		return [0, 1]
	else:
		(a, b) = fib(n // 2)
		c = a % m * (b % m * 2 - a % m) % m
		d = a % m * (a % m) % m + b % m * b % m % m
		if n % 2 == 0:
			return [c, d]
		else:
			return [d, c + d]

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()
for _ in range(int(input())):
	(a, b) = arrIN()
	if a > b:
		(a, b) = (b, a)
	d = b - a
	if d == 0:
		print(0)
	else:
		x = 1
		ans = 0
		while d > 0 or d % 2:
			d -= x
			ans += 1
			x += 1
		print(ans)


v = [0]
for i in range(1, 10 ** 5):
	v.append(v[-1] + i)
c = int(input())
for casos in range(c):
	(a, b) = map(int, input().split())
	sw = 0
	if a == b:
		print(0)
	elif a < b:
		while sw == 0:
			l = a + b
			for i in range(len(v)):
				p = l + v[i]
				if p % 2 == 0:
					p = p // 2
					if p >= a and p >= b:
						print(i)
						sw = 1
						break
	else:
		while sw == 0:
			l = a + b
			for i in range(len(v)):
				p = l + v[i]
				if p % 2 == 0:
					p = p // 2
					if p >= a and p >= b:
						print(i)
						sw = 1
						break


def cal(k):
	rs = 0
	for i in range(1000000000):
		rs += i
		if rs == k:
			return i
		if rs > k and rs - k & 1 == 0:
			return i
for test in range(int(input())):
	(a, b) = map(int, input().split())
	print(cal(abs(a - b)))


M = 1000000

class que:

	def __init__(self):
		self.p1 = 0
		self.p2 = 0
		self.st = [0] * M

	def push(self, x):
		self.st[self.p1] = x
		self.p1 = (self.p1 + 1) % M

	def front(self):
		if self.p1 != self.p2:
			self.p2 = (self.p2 + 1) % M
			return self.st[self.p2 - 1]
n = int(input())
for ppppp in range(n):
	(a, b) = map(int, input().split())
	x = abs(a - b)
	ans = 0
	while x > 0:
		ans += 1
		x -= ans
	if x < 0:
		x += ans
		ans -= 1
		if x % 2 == 0:
			if ans % 2 == 0:
				ans += 3
			else:
				ans += 1
		elif ans % 2 == 0:
			ans += 1
		else:
			ans += 2
	print(ans)


t = int(input())
for u in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		s = a - b
	elif a < b:
		s = b - a
	else:
		s = 0
	k = s % 2
	i = int((2 * s) ** 0.5)
	p = i * (i + 1) // 2 - s
	while p < 0:
		i += 1
		p = i * (i + 1) // 2 - s
	while 1 > 0:
		if k == 0:
			if i % 4 == 0:
				print(i)
				break
			elif (i + 1) % 4 == 0:
				print(i)
				break
			else:
				i += 1
		elif i % 4 == 0:
			i += 1
		elif (i + 1) % 4 == 0:
			i += 1
		else:
			print(i)
			break


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

def f(x, df):
	sm = x * (x + 1) // 2
	if sm < df:
		return 0
	return sm % 2 == df % 2

def dolv():
	(x, y) = mlt()
	if x == y:
		print(0)
		return
	res = 0
	df = abs(x - y)
	while not f(res, df):
		res += 1
	print(res)
for _ in range(int(input())):
	dolv()


import math
t = int(input())
while t:
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	else:
		ax = max(a, b)
		bx = min(a, b)
		ys = ax - bx
		sx = (-1 + math.sqrt(1 + 8 * ys)) / 2
		n = int(sx)
		i = n + 1
		done = 1
		while done:
			x = i * (i + 1) // 2
			xi = x - ys
			if xi % 2 == 0 and xi != 0:
				done = 0
				i -= 1
			i += 1
		yx = str(sx)
		if yx[len(yx) - 1] == '0':
			print(int(sx))
		else:
			print(i)
	t -= 1


def summ(n):
	return n * (n + 1) // 2
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a == b:
		print(0)
		continue
	n = 1
	while 1:
		XX = a + b + summ(n)
		if XX % 2 == 0:
			x = XX // 2
			if x - a >= 0 and x - b >= 0 and (2 * x - a - b == summ(n)):
				print(n)
				break
		n += 1


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	mid = 0
	while True:
		lft = mid * (mid + 1) // 2 - a + b
		if lft % 2 == 0 and 0 <= lft / 2 <= mid * (mid + 1) // 2:
			break
		mid += 1
	print(mid)


import sys
input = sys.stdin.readline
import bisect
t = int(input())
tri = [i * (i + 1) // 2 for i in range(10 ** 5)]
for _ in range(t):
	(a, b) = map(int, input().split())
	dif = abs(a - b)
	idx = bisect.bisect_left(tri, dif)
	if tri[idx] == dif:
		print(idx)
		continue
	for i in range(idx, idx + 10):
		if tri[i] > dif and (tri[i] - dif) % 2 == 0:
			print(i)
			break


gpf = [0]
for i in range(1, 200000):
	gpf.append(i * (i + 1) // 2)
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	ind = 0
	for i in range(len(gpf)):
		if gpf[i] >= d:
			ind = i
			break
	if gpf[ind] == d:
		print(ind)
	elif not (gpf[ind] - d) % 2:
		print(ind)
	else:
		while (gpf[ind] - d) % 2:
			ind += 1
		print(ind)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	x = abs(a - b)
	for i in range(10 ** 9):
		t = i * (i + 1) // 2
		if x % 2 != t % 2:
			continue
		elif x <= t:
			print(i)
			break


import math

def main():
	(a, b) = map(int, input().split())
	k = abs(a - b)
	l = (-1 + math.sqrt(1 + 8 * k)) / 2
	l = math.ceil(l)
	if k % 2 == 1:
		while l % 4 != 1 and l % 4 != 2:
			l += 1
	else:
		while l % 4 != 3 and l % 4 != 0:
			l += 1
	print(l)
t = int(input())
for i in range(t):
	main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	k = 1
	while a + k <= b:
		a += k
		k += 1
	if a == b:
		print(k - 1)
		continue
	for i in range(3):
		a += k
		k += 1
		d = a - b
		if d % 2 == 0:
			print(k - 1)
			break


for case in range(int(input())):
	cnt = 0
	x = input().split()
	m = abs(int(x[0]) - int(x[1]))
	while m > 0:
		cnt += 1
		m -= cnt
	m = -m
	while m & 1:
		cnt += 1
		m += cnt
	print(cnt)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	d = abs(a - b)
	if d == 0:
		print(0)
		continue
	ans = 0
	step = 0
	for step in range(1, 10 ** 5):
		ans = ans + step
		if ans >= d and (ans - d) % 2 == 0:
			break
	print(step)


c = 'Just test!!!'
for _ in [0] * int(input()):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	i = int(((8 * d + 1) ** 0.5 - 1) / 2)
	s = i * (i + 1) // 2
	while (s ^ d) % 2 or s < d:
		i += 1
		s += i
	print(i)


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	df = 2 * abs(a - b)
	val = 1 + 4 * df
	val = math.sqrt(val) - 1
	val = math.ceil(val) / 2
	val = math.ceil(val)
	f = abs(a - b)
	sum = val * (val + 1) // 2
	if (sum - f) % 2 == 1:
		val += 1
		sum = val * (val + 1) // 2
	if (sum - f) % 2 == 1:
		val += 1
		sum = val * (val + 1) // 2
	print(val)


from random import *
n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	c = abs(a - b)
	s = 0
	i = 1
	while s < c or (s + c) % 2 != 0:
		s += i
		i += 1
	print(i - 1)


N = int(input())
for i in range(N):
	(a, b) = map(int, input().split())
	diff = abs(a - b)
	count = 0
	while diff > 0 or diff % 2 != 0:
		count += 1
		diff -= count
	print(count)


t = int(input())
for i in range(t):
	(a, b) = [int(i) for i in input().split()]
	(a, b) = (min(a, b), max(a, b))
	k = b - a
	n = (-1 + (1 + 8 * k) ** 0.5) / 2
	n = int(n)
	k -= n * (n + 1) // 2
	if k == 0:
		print(n)
		continue
	n += 1
	k -= n
	if abs(k) % 2 == 0:
		print(n)
	elif abs(k - n - 1) % 2 == 0:
		print(n + 1)
	else:
		print(n + 2)


def solve(n):
	if int((8 * n + 1) ** (1 / 2)) == (8 * n + 1) ** (1 / 2):
		x = (int((8 * n + 1) ** (1 / 2)) - 1) // 2
	else:
		x = (int((8 * n + 1) ** (1 / 2)) + 1) // 2
	c = x * (x + 1) // 2
	if (c - n) % 2 == 0:
		return x
	elif ((x + 1) * (x + 2) // 2 - n) % 2 == 0:
		return x + 1
	else:
		return x + 2
t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	print(solve(abs(a - b)))


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split(' '))
	dif = abs(a - b)
	if dif == 0:
		print(0)
	else:
		(l, r) = (1, 100000)
		while l < r:
			m = (l + r) // 2
			res = (m + 1) * m / 2
			if res == dif:
				print(m)
				break
			elif res < dif:
				l = m + 1
			else:
				r = m
		else:
			while ((l + 1) * l / 2 - dif) % 2 == 1:
				l += 1
			print(l)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	d = abs(n - k)
	q = 0
	v = 0
	while v < d:
		q = q + 1
		v = v + q
	if v == d:
		print(q)
	elif v % 2 == d % 2:
		print(q)
	else:
		while v % 2 != d % 2:
			q = q + 1
			v = v + q
		print(q)


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time

def I():
	return int(input())

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

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

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 + 10 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def GI(V, E, Directed=False, index=0):
	org_inp = []
	g = [[] for i in range(n)]
	for i in range(E):
		inp = LI()
		org_inp.append(inp)
		if index == 0:
			inp[0] -= 1
			inp[1] -= 1
		if len(inp) == 2:
			(a, b) = inp
			g[a].append(b)
			if not Directed:
				g[b].append(a)
		elif len(inp) == 3:
			(a, b, c) = inp
			aa = (inp[0], inp[2])
			bb = (inp[1], inp[2])
			g[a].append(bb)
			if not Directed:
				g[b].append(aa)
	return (g, org_inp)

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
t = I()
for _ in range(t):
	ans = 0
	(a, b) = LI()
	if a > b:
		(a, b) = (b, a)
	if a == b:
		print(0)
		continue
	nb = max(int((2 * (b - a)) ** 0.5) - 3, 0)
	for i in range(nb, nb * 2 + 100):
		if a + i * (i + 1) // 2 >= b and (a + i * (i + 1) // 2 - b) % 2 == 0:
			print(i)
			break


import math
for t in range(int(input())):
	(a, b) = map(int, input().split())
	diff = abs(a - b)
	if diff % 2 == 0:
		j = math.sqrt(diff * 2)
		i = int(j)
		while True:
			sumn = i * (i + 1) // 2
			if sumn >= diff and sumn % 2 == 0:
				print(i)
				break
			else:
				i = i + 1
	else:
		j = math.sqrt(diff * 2)
		i = int(j)
		while True:
			sumn = i * (i + 1) // 2
			if sumn >= diff and sumn % 2 != 0:
				print(i)
				break
			else:
				i = i + 1


T = int(input())
for case in range(0, T):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	i = 0
	while a < b or (a - b) % 2 == 1:
		i += 1
		a += i
	print(i)


import math
t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	x = abs(a - b)
	diff = x
	x = math.sqrt(1 + 8 * x) - 1
	if x % 2 != 0:
		x = int(x) // 2 + 1
	else:
		x = int(x) // 2
	val = x * (x + 1) // 2
	if val % 2 != 0 and diff % 2 == 0:
		y1 = x + 1
		val1 = y1 * (y1 + 1) // 2
		y2 = x + 2
		val2 = y2 * (y2 + 1) // 2
		if val1 % 2 == 0:
			x = y1
		else:
			x = y2
	if val % 2 == 0 and diff % 2 != 0:
		y1 = x + 1
		val1 = y1 * (y1 + 1) // 2
		y2 = x + 2
		val2 = y2 * (y2 + 1) // 2
		if val1 % 2 != 0:
			x = y1
		else:
			x = y2
	print(int(x))


def main():
	for t in range(int(input())):
		(n, m) = map(int, input().split())
		if n == m:
			print(0)
		else:
			diff = -1 * abs(n - m)
			k = 1
			while diff < 0:
				diff += k
				k += 1
			if diff % 2 == 0:
				print(k - 1)
			else:
				diff += k
				if diff % 2 == 0:
					print(k)
				else:
					print(k + 1)
main()


from math import ceil
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	t1 = max(a, b)
	t2 = min(a, b)
	x = t1 - t2
	s = ceil((-1 + (1 + 8 * x) ** (1 / 2)) / 2)
	k = s * (s + 1) // 2
	t2 = t2 + k
	if (-t1 + t2) % 2 == 1:
		s = s + 1
		t2 = t2 + s
	if (-t1 + t2) % 2 == 1:
		s = s + 1
		t2 = t2 + s
	print(s)


summation = []
p = 0
for i in range(100001):
	p += i
	summation.append(p)
for i in range(int(input())):
	(c, d) = map(int, input().split())
	a = min(c, d)
	b = max(c, d)
	diff = b - a
	ans = 1000000001
	for i in range(100001):
		if a + summation[i] >= b:
			if (a + summation[i] - b) % 2 == 0:
				ans = min(ans, i)
	print(ans)


from math import *
t = int(input())
for numbers in range(t):
	(a, b) = map(int, input().split())
	i = max(a, b)
	j = min(a, b)
	g = i - j
	if a == b:
		print(0)
	else:
		n = ceil((-1 + (1 + 8 * g) ** 0.5) / 2)
		for values in range(n, n + 100):
			if (values * (values + 1) / 2 - g) % 2 == 0:
				n = values
				break
			else:
				continue
		print(n)


sums = []

def solve(a, b):
	d = abs(a - b)
	if d == 0:
		return 0
	else:
		p = d % 2
		n = int((2 * d) ** 0.5)
		while True:
			s = n * (n + 1) // 2
			if s % 2 == p and s >= d:
				return n
			n += 1
t = int(input())
for i in range(t):
	(a, b) = tuple(map(int, input().strip().split()))
	print(solve(a, b))


def ok(x):
	res = x * (x + 1) // 2
	return res >= delta and res & 1 == delta & 1
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	delta = abs(a - b)
	ret = 0
	while not ok(ret):
		ret += 1
	print(ret)


t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	cha = b - a
	if cha == 0:
		print(0)
		continue
	(s, use, i) = (1, 1, 2)
	while not (s >= cha and s % 2 == cha % 2):
		use += 1
		s += i
		i += 1
	print(use)


import math
import sys
from collections import defaultdict, Counter, deque, OrderedDict
import bisect
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]
from itertools import accumulate, groupby
import sys
mod = 1000000007
A = [0, 1]
t = 1
for i in range(2, 100000):
	t += i
	A.append(t)
for _ in range(int(input())):
	(a, b) = ilele()
	if a == b:
		print(0)
	else:
		if a > b:
			(a, b) = (b, a)
		d = b - a
		c = bisect.bisect_left(A, d)
		if (a + A[c] - b) % 2 == 0:
			print(c)
		elif c % 2 != 0:
			print(c + 2)
		else:
			print(c + 1)


from math import sqrt, ceil
t = int(input())
S = lambda x: x * (x + 1) // 2
for _ in range(t):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	i = int(ceil(0.5 * (-1.0 + sqrt(1.0 + 8 * d))))
	while (S(i) + d) % 2:
		i += 1
	print(i)


import sys
input = sys.stdin.readline

def main():
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		i = 0
		while True:
			s1 = i * (i + 1) // 2
			x = b - a + s1
			if x % 2 == 0 and x >= 0:
				x //= 2
				y = s1 - x
				if y >= 0:
					break
			i += 1
		print(i)
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	mx = max(a, b)
	i = 0
	n = 1
	while 1:
		if (a + +b + i) // 2 >= mx and (a + b + i) % 2 == 0:
			print(n - 1)
			break
		else:
			i += n
			n += 1


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	(a, b) = map(int, stdin.readline().split())
	diff = abs(a - b)
	(ans, cur) = (0, 0)
	while cur < diff or (cur - diff) % 2 == 1:
		ans += 1
		cur += ans
	stdout.write('{}\n'.format(ans))


import bisect
even = []
odd = []
s = 0
for i in range(0, 10 ** 5):
	s += i
	if s % 2 == 1:
		odd.append([s, i])
	else:
		even.append([s, i])
t = int(input())
for _ in range(t):
	(a, b) = [int(i) for i in input().split()]
	d = max(a, b) - min(a, b)
	if d % 2 == 0:
		pos = bisect.bisect_left(even, [d, 0])
		print(even[pos][1])
	else:
		pos = bisect.bisect_left(odd, [d, 0])
		print(odd[pos][1])


def solve(a, b):
	if a == b:
		return 0
	if a > b:
		(a, b) = (b, a)
	diff = b - a
	k = 1
	while diff > 0:
		diff -= k
		k += 1
	if diff % 2 == 0:
		return k - 1
	else:
		diff -= k
		if diff % 2 == 0:
			return k
		else:
			return k + 1

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


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
		continue
	if a > b:
		(a, b) = (b, a)
	i = 0
	while i * (i + 1) // 2 - abs(b - a) < 0 or (i * (i + 1) // 2 - abs(b - a)) % 2 != 0:
		i = i + 1
	print(i)


t = int(input())
for x in range(t):
	a = input().split()
	k = []
	for i in a:
		k.append(int(i))
	k.sort()
	for i in range(10 ** 5):
		if i * (i + 1) // 2 >= k[1] - k[0] and (i * (i + 1) // 2 - (k[1] - k[0])) % 2 == 0:
			print(i)
			break


from math import sqrt
tc = int(input())
while tc != 0:
	tc -= 1
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	ans = 0
	p = int(100000.0) + 1
	for i in range(0, p + 1):
		x = b - a + i * (i + 1) // 2
		if x % 2 != 0:
			continue
		x = x // 2
		y = x + a - b
		if y >= 0 and x >= 0 and (x + a == b + y):
			ans = i
			break
	print(ans)


import math

def f(a, b):
	diff = abs(a - b)
	if diff == 0:
		return 0
	m = (math.sqrt(8 * diff + 1) - 1) / 2.0
	n = int(math.ceil(m))
	while True:
		sum_ = n * (n + 1) // 2
		if (sum_ + diff) % 2 == 0:
			return n
		n += 1
assert f(0, 5) == 5
assert f(0, 1) == 1
assert f(0, 3) == 2
assert f(1, 5) == 3
assert f(1, 3) == 3
assert f(1, 2) == 1
assert f(1, 4) == 2
assert f(20, 30) == 4
assert f(10, 10) == 0
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	ans = f(a, b)
	print(ans)


import math
t = int(input())
while t > 0:
	x = input()
	x = x.split()
	a = int(x[0])
	b = int(x[1])
	if a > b:
		(a, b) = (b, a)
	mx = max(a, b)
	n = math.ceil((-1 + math.sqrt(1 + 8 * (b - a))) / 2)
	while True:
		k = a + b + (n * (n + 1) >> 1)
		if k % 2 == 0 and k / 2 >= mx:
			print(n)
			break
		else:
			n += 1
	t -= 1


import math
t = int(input())
for _ in range(t):
	(a, b) = sorted(map(int, input().split()))
	x = math.ceil(math.sqrt((b - a) * 2) - 0.5)
	while (x * (x + 1) // 2 + b - a) % 2:
		x += 1
	print(x)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print('0')
	else:
		if a > b:
			(b, a) = (a, b)
		Sum = a
		for i in range(1, 100000000):
			Sum = Sum + i
			if Sum >= b and (Sum - b) % 2 == 0:
				print(i)
				break


t = int(input())
for i in range(t):
	s = input().split()
	a = int(s[0])
	b = int(s[1])
	x = max(a, b) - min(a, b)
	s = 0
	i = 1
	while x > 0:
		x -= i
		i += 1
		s += 1
	if x < 0:
		q = a + b + (max(a, b) - min(a, b) - x)
		while q % 2 != 0:
			q += i
			i += 1
			s += 1
	print(s)


import sys
input = sys.stdin.buffer.readline

def solution():
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		if a < b:
			(a, b) = (b, a)
		k = 0
		while True:
			if k * (k + 1) // 2 >= a - b and (a - b) % 2 == k * (k + 1) // 2 % 2:
				print(k)
				break
			k += 1
solution()


def binary(data, target, low, high):
	if low > high:
		return low
	else:
		mid = (low + high) // 2
		if data[mid] >= target:
			return binary(data, target, low, mid - 1)
		else:
			return binary(data, target, mid + 1, high)
from math import ceil, sqrt

def solve(x):
	return ceil((-1 + sqrt(1 + 8 * x)) / 2)

def solve2(x):
	return (-1 + sqrt(1 + 8 * x)) / 2
dd1 = [0]
for i in range(3, 50000, 4):
	dd1.append(i)
	dd1.append(i + 1)
dd2 = [0]
for i in range(1, 50000, 4):
	dd2.append(i)
	dd2.append(i + 1)
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	t = abs(a - b)
	k = solve2(t)
	if t % 2 == 0:
		res = dd1[binary(dd1, k, 0, len(dd1) - 1)]
	else:
		res = dd2[binary(dd2, k, 0, len(dd1) - 1)]
	print(res)


from math import floor, sqrt
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
		continue
	for x in range(floor(sqrt(2 * abs(a - b))), 10 ** 9):
		ans = 2 * (a + b) + x * (x + 1)
		if ans % 4 == 0 and ans // 4 >= max(a, b):
			print(x)
			break


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')
testcases = int(input())
for j in range(testcases):
	(a, b) = map(int, input().split())
	diff = max(a, b) - min(a, b)
	num = 0
	for s in range(2 * diff + 1):
		if (diff + s * (s + 1) // 2) % 2 == 0 and s * (s + 1) // 2 >= diff:
			num = s
			break
	print(num)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	num1 = max(a, b) - min(a, b)
	a = num1
	val = -1
	l = 1
	r = a
	while l < r:
		mid = (l + r) // 2
		if mid * (mid + 1) < a * 2:
			val = mid + 1
			l = mid + 1
		else:
			r = mid
	if a == 1 or a == 0:
		val = num1
	while ((val + 1) * val // 2 - a) % 2 & 1:
		val += 1
	print(val)


n = int(input())
m = []
for i in range(n):
	(a, b) = input().split()
	m.append([a, b])
for i in m:
	k = abs(int(i[0]) - int(i[1]))
	t = int(pow(1 + 8 * k, 0.5)) // 2 - 1
	p = 0
	while p <= 3 * k:
		p = t * (t + 1) // 2
		if p == k:
			break
		if p - k > 0 and (p - k) % 2 == 0:
			break
		t += 1
	r = pow(1 + 8 * p, 0.5)
	result = (r - 1) // 2
	print(int(result))


for tc in range(int(input())):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	tt = int((2 * d) ** 0.5)
	if a == b:
		print(0)
	elif abs(a - b) == 1:
		print(1)
	elif 2 * d == tt ** 2 + tt:
		print(tt)
	elif abs(a - b) > 1:
		i = tt
		while i < d + d:
			t = i * (i + 1) // 2
			if t > d:
				if (t + d) % 2 == 0:
					print(i)
					break
			i += 1


for tests in range(int(input())):
	(a, b) = map(int, input().split())
	diff = abs(a - b)
	if diff == 0:
		print(0)
		continue
	n = 1
	k = 0
	while True:
		k += n
		if k >= diff and (k - diff) % 2 == 0:
			print(n)
			break
		n += 1


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


import math
t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	diff = abs(a - b)
	n = int((-1 + math.sqrt(1 + 8 * abs(a - b))) // 2)
	while (1 + n) * n // 2 < diff:
		n += 1
	while (1 + n) * n // 2 % 2 != (a + b) % 2:
		n += 1
	print(int(n))


from math import *
for x in range(int(input())):
	(a, b) = map(int, input().split())
	c = max(a, b) - min(a, b)
	nmin = floor((-1 + sqrt(1 + 8 * c)) / 2)
	for n in range(nmin, 1000000000):
		sum = 0.5 * n * (n + 1)
		v = (sum - c) / 2
		if sum >= c and (sum + a + b) % 2 == 0 and (v + max(a, b) == sum + min(a, b) - v):
			print(n)
			break


kl = int(input())
for l in range(kl):
	(a, b) = [int(i) for i in input().split()]
	k = max(a, b) - min(a, b)
	n = ((1 + 8 * k) ** 0.5 - 1) / 2
	d = n - int(n)
	n = int(n + 1 - (1 - d) // 1)
	print(n + (1 + n % 2) * (((n - 1) % 4 // 2 + (k + 1) % 2) % 2))


from sys import stdin
n = int(stdin.readline().strip())
dif = 0

def can(x):
	y = x * (x + 1)
	y = y // 2
	if y <= dif:
		return True
	return False

def fur(x):
	y = x * (x + 1)
	y = y // 2
	return y
for c in range(n):
	(a, b) = map(int, stdin.readline().strip().split())
	dif = abs(a - b)
	low = 0
	high = 10 ** 9
	while high - low > 1:
		mid = low + high
		mid = mid // 2
		if can(mid):
			low = mid
		else:
			high = mid
	for i in range(max(low - 7, 0), high + 7):
		if fur(i) >= dif and dif % 2 == fur(i) % 2:
			print(i)
			break


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

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

def cin():
	return map(int, sin().split())

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

def sin():
	return input()

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

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

def main():
	t = inin()
	for _ in range(t):
		(j, k) = cin()
		x = abs(j - k)
		i = int(math.sqrt(x))
		i = int(math.sqrt(x - i))
		i = max(0, i)
		while 1:
			if i * (i + 1) == 2 * x:
				ans = i
				break
			elif i * (i + 1) > 2 * x:
				p = i * (i + 1) - 2 * x
				p //= 2
				if p % 2 == 0:
					ans = i
				else:
					ans = i + 1
					if i % 2 == 1:
						ans = i + 2
				break
			i += 1
		print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

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

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	m = abs(a - b)
	n = int((m * 2) ** (1 / 2))
	while n * (n + 1) / 2 < m or (n * (n + 1) / 2 - m) % 2 == 1:
		n += 1
	print(n)


from math import ceil
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	k = abs(a - b)
	n = (-1 + (1 + 8 * k) ** 0.5) / 2
	c = ceil(n)
	target = (1 + c) * c // 2
	dif = target - k
	if dif % 2 == 0:
		print(c)
	elif c % 2 == 0:
		print(c + 1)
	else:
		print(c + 2)


t = int(input())
for i in range(t):
	ans = 1
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a == b:
		print(0)
		continue
	while a < b:
		a += ans
		ans += 1
	while (a - b) % 2 != 0:
		a += ans
		ans += 1
	print(ans - 1)


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

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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

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

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

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

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

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

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

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

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

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

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

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

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	(a, b) = sep()
	if a == b:
		print(0)
		return
	if b < a:
		(a, b) = (b, a)
	n = 1
	while a + n * (n + 1) // 2 < b:
		n += 1
	if a + n * (n + 1) // 2 == b:
		print(n)
	else:
		while n * (n + 1) // 2 % 2 != (b - a) % 2:
			n += 1
		print(n)
testcase(int(inp()))


t = int(input())
for u in range(t):
	i = input().split()
	d = abs(int(i[0]) - int(i[1]))
	for j in range(100000):
		if d + d <= j * (j + 1) and j * (j + 1) // 2 % 2 == d % 2:
			print(j)
			break


from math import ceil
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = ceil(((1 + 8 * abs(a - b)) ** 0.5 - 1) / 2)
	while x * (x + 1) // 2 % 2 != abs(a - b) % 2:
		x += 1
	print(x)


n = int(input())
import math
for _ in range(n):
	(a, b) = [int(i) for i in input().split()]
	sub = abs(a - b)
	M = int(math.sqrt(sub * 2))
	if M == 0:
		print(M)
		continue
	for m in range(M + 1, 0, -1):
		under = m * (m - 1) // 2
		if under < sub:
			upper = m * (m + 1) // 2
			if (upper - sub) % 2 == 0:
				print(m)
			elif (m + 1) % 2:
				print(m + 1)
			else:
				print(m + 2)
			break
	else:
		print(M)


t = int(input())
for i in range(t):
	c = list(map(int, input().split()))
	x = abs(c[0] - c[1])
	k = 0
	p = (k + 1) * k // 2
	while p < x or (p - x) % 2 != 0:
		k += 1
		p = (k + 1) * k // 2
	print(k)


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	diff = abs(a - b)
	n_min_unrounded = (-1 + math.sqrt(1 + 8 * diff)) / 2
	if math.isclose(n_min_unrounded, int(n_min_unrounded)):
		n_min = int(n_min_unrounded)
	else:
		n_min = int(n_min_unrounded) + 1
	lhs = n_min * (n_min + 1) // 2
	if lhs % 2 == diff % 2:
		print(n_min)
	elif n_min % 2 == 1:
		print(n_min + 2)
	else:
		print(n_min + 1)


import math
for case in range(int(input())):
	read = list(map(int, input().split()))
	(a, b) = read
	d = int(abs(a - b))
	n = (math.sqrt(8 * d + 1) - 1) / 2
	if n > int(n):
		n = int(n) + 1
	flag = True
	while flag:
		k = n * (n + 1) // 2
		k = int(k)
		if k - d & 1 == 0:
			flag = False
			break
		n += 1
		n = int(n)
	print(int(n))


import math
t = int(input())
l = []
for i in range(50000):
	l.append(i * (i + 1) // 2)
while t:
	(a, b) = map(int, input().split())
	a1 = max(a, b)
	b1 = min(a, b)
	a1 = a1 - b1
	for i in range(50000):
		if l[i] == a1:
			ans = i
			break
		elif l[i] > a1:
			if l[i] % 2 == 0 and a1 % 2 == 0:
				ans = i
				break
			if l[i] % 2 != 0 and a1 % 2 != 0:
				ans = i
				break
	print(ans)
	t -= 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(0)
	else:
		i = 1
		while 1:
			r = i * (i + 1) // 2
			if (abs(b - a) + r) % 2 == 0 and (abs(b - a) + r) // 2 <= r:
				break
			i += 1
		print(i)


import bisect
su = [1]
ev = [0]
od = [0]
for i in range(2, 100001):
	if su[-1] % 2 == 0:
		ev.append(su[-1])
		od.append(od[-1])
	else:
		od.append(su[-1])
		ev.append(ev[-1])
	su.append(su[-1] + i)
res = []
t = int(input())
while t:
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	d = b - a
	if d % 2 == 0:
		pos = bisect.bisect_left(ev, d)
	else:
		pos = bisect.bisect_left(od, d)
	print(pos)
	t -= 1


for hasju in range(int(input())):
	(a, b) = map(int, input().split())
	raz = abs(a - b)
	razch = raz % 2
	c = 1
	while raz > 0:
		raz -= c
		c += 1
	c -= 1
	while (c - 1) // 2 % 2 == razch:
		c += 1
	print(c)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	count = 0
	turn = 1
	for i in range(0, 50000):
		x = (b - a) / 2 + i * (i + 1) / 4
		y = (a - b) / 2 + i * (i + 1) / 4
		if x % 1 == 0 and y % 1 == 0 and (a + x == b + y) and (x + y == i * (i + 1) / 2) and (x >= 0) and (y >= 0):
			ans = i
			break
	print(ans)


arr = []
for i in range(45000):
	arr.append((i + 1) * (i + 2) // 2)
t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	d = abs(a - b)
	if d == 0:
		print(0)
	else:
		for j in range(45000):
			if arr[j] >= d:
				s = j + 1
				c = abs(arr[j] - d)
				break
		if c % 2 == 0:
			print(s)
		elif s % 2 == 0:
			print(s + 1)
		else:
			print(s + 2)


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if b > a:
		(a, b) = (b, a)
	n = math.ceil((-1 + math.sqrt(1 + 8 * (a - b))) / 2)
	while 1:
		s = a + b + n * (n + 1) // 2
		if s % 2 == 0:
			print(n)
			break
		n += 1


def solve(a, b):
	a = abs(a - b)
	s = 0
	i = 0
	for i in range(a):
		s += i
		if s >= a:
			break
	if s == a:
		return i
	elif (s - a) % 2 == 0:
		return i
	elif i % 2 == 0:
		return i + 1
	else:
		return i + 2
for i in range(int(input())):
	(a, b) = map(int, input().split())
	print(solve(a, b))


def func(m):
	return m * (m + 1) // 2

def check(m, d):
	return func(m) >= d
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	low = 0
	up = 100000000000000000
	d = abs(a - b)
	ans = None
	while low <= up:
		mid = (low + up) // 2
		if check(mid, d):
			ans = mid
			up = mid - 1
		else:
			low = mid + 1
	while (func(ans) + d) % 2 != 0:
		ans += 1
	print(ans)


t = int(input())
for i in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	a = L[0]
	b = L[1]
	n = abs(a - b)
	i = 0
	s = 0
	while True:
		if s - n >= 0 and (s - n) % 2 == 0:
			break
		i += 1
		s += i
	print(i)


from sys import stdin, stdout, setrecursionlimit
stdin.readline

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

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
from bisect import bisect_right as br, bisect_left as bl
import heapq

def solve(a, b):
	if a == b:
		return 0
	if a > b:
		(a, b) = (b, a)
	i = 1
	ans = 0
	while ans < b - a:
		ans = i * (i + 1) // 2
		i += 1
	if ans == b - a:
		return i - 1
	if b - a & 1 and ans & 1:
		return i - 1
	elif not b - a & 1:
		while ans & 1:
			ans += i
			i += 1
		return i - 1
	elif b - a & 1:
		while not ans & 1:
			ans += i
			i += 1
		return i - 1
for _ in range(it()):
	(a, b) = mp()
	print(solve(a, b))


import math as m
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	x = min(a, b)
	y = max(a, b)
	a = 1
	b = 1
	c = -2 * (y - x)
	d = b ** 2 - 4 * a * c
	n = (-b + m.sqrt(d)) / (2 * a)
	n = m.ceil(n)
	if (x + y) % 2 == 0:
		if n % 4 == 1:
			n += 2
		if n % 4 == 2:
			n += 1
	else:
		if n % 4 == 0:
			n += 1
		if n % 4 == 3:
			n += 2
	print(n)


def fun(n):
	p = int(pow(2 * n, 1 / 2))
	if p * (p + 1) / 2 < n and (p + 1) * (p + 2) >= n:
		return p + 1
	else:
		return p
n = int(input())
for i in range(0, n):
	(a, b) = map(int, input().split())
	t = max(a, b) - min(a, b)
	m = fun(t)
	if (m * (m + 1) // 2 - t) % 2 == 0:
		print(m)
	elif ((m + 1) * (m + 2) // 2 - t) % 2 == 0:
		print(m + 1)
	else:
		print(m + 2)


def s(n):
	return n * (n + 1) // 2

def c(n, d):
	m = s(n)
	if m < d:
		return False
	return m % 2 == d % 2
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	q = abs(a - b)
	n = 0
	while not c(n, q):
		n += 1
	print(n)


t = int(input())
while t:
	t += -1
	(a, b) = [int(x) for x in input().split()]
	if a > b:
		(a, b) = (b, a)
	if a == b:
		print(0)
	else:
		i = 1
		s = a + b
		while 1:
			s += i
			if s % 2 == 0 and s // 2 >= b:
				print(i)
				break
			i -= -1


if True:
	a = [1]
	x = 2
	while x < 44999:
		a.append(a[-1] + x)
		x += 1
	for _ in range(int(input())):
		(n, x) = map(int, input().split())
		if n == x:
			print(0)
		else:
			p = 1
			for j in a:
				if j >= abs(n - x) and j % 2 == abs(n - x) % 2:
					print(p)
					break
				p += 1


import math
for _ in range(int(input())):
	(k, k1) = map(int, input().split())
	a = min(k, k1)
	b = max(k, k1)
	if a == b:
		print(0)
	else:
		c = (b - a) * 2
		r = math.ceil((-1 + math.sqrt(1 + 4 * c)) / 2)
		e = a + r * (r + 1) // 2
		if e == b:
			print(r)
		else:
			diff = e - b
			if diff % 2 == 0:
				print(r)
			elif (diff + r + 1) % 2 == 0:
				print(r + 1)
			else:
				print(r + 2)


from sys import stdin

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

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

def intsput():
	return map(int, sinput())
t = intput()
for _ in range(t):
	(a, b) = intsput()
	diff = abs(a - b)
	s = 0
	for i in range(100000000000):
		s += i
		if s >= diff and (diff - s) % 2 == 0:
			break
	print(i)


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

def solve():
	(a, b) = inp()
	x = abs(a - b)
	i = 0
	s = 0
	if x == 0:
		return 0
	while s < x or s % 2 != x % 2:
		i += 1
		s += i
	return i

def main():
	t = int(input())
	while t:
		print(solve())
		t -= 1
main()


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	(a, b) = (max(a, b), min(a, b))
	d = a - b
	ans = 0
	if d != 0:
		ans = int(((1 + 8 * d) ** (1 / 2) - 1) / 2) - 1
	while (ans * (ans + 1) // 2 - d) % 2 != 0 or ans * (ans + 1) // 2 - d < 0:
		ans += 1
	print(ans)


import math
N = int(input())
for example in range(N):
	(a, b) = input().split()
	diff = abs(int(b) - int(a))
	if diff == 0 or diff == 1:
		print(diff)
	else:
		nearest_n = int(math.sqrt(2 * diff))
		if nearest_n * (nearest_n + 1) < 2 * diff:
			nearest_n = nearest_n + 1
		sum_till_nearest_n = nearest_n * (nearest_n + 1) / 2
		if (sum_till_nearest_n - diff) % 2 == 0:
			print(nearest_n)
		else:
			nearest_n = nearest_n + 1
			sum_till_nearest_n = nearest_n * (nearest_n + 1) / 2
			if (sum_till_nearest_n - diff) % 2 == 0:
				print(nearest_n)
			else:
				print(nearest_n + 1)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	(a, b) = map(int, sys.stdin.readline().split(' '))
	if a == b:
		print(0)
		continue
	d = abs(a - b)
	k = int((-1 + (1 + 8 * d) ** 0.5) // 2)
	val = k * (k + 1)
	val //= 2
	while 1:
		if val >= d and val % 2 == d % 2:
			break
		k += 1
		val += k
	print(k)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


import sys

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

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

def oint():
	return int(input())
t = oint()
for _ in range(t):
	(a, b) = rint()
	d = abs(a - b)
	for i in range(10 ** 8):
		s = i * (i + 1) // 2
		if (s - d) % 2:
			continue
		x = (s - d) // 2
		if x < 0:
			continue
		print(i)
		break


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = sorted([a, b])
	diff = b - a
	low = 0
	high = diff + 1
	while low < high - 1:
		mid = (low + high) // 2
		if mid * (mid + 1) // 2 < diff:
			low = mid
		else:
			high = mid
	for i in range(low, high + 1):
		if i * (i + 1) // 2 >= diff:
			ans = i
			break
	if (ans * (ans + 1) // 2 + a - b) % 2 == 0:
		print(ans)
	else:
		ans += 1
		if (ans * (ans + 1) // 2 + a - b) % 2 == 0:
			print(ans)
		else:
			ans += 1
			if (ans * (ans + 1) // 2 + a - b) % 2 == 0:
				print(ans)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	l = -1
	r = b - a
	while r - l > 1:
		m = (l + r) // 2
		if a + (1 + m) * m // 2 >= b:
			r = m
		else:
			l = m
	if (a + (1 + r) * r // 2 - b) % 2 == 0:
		print(r)
	elif r % 2 == 1:
		print(r + 2)
	else:
		print(r + 1)


from bisect import bisect_left
lst = [0, 1]
i = 2
while lst[-1] < 10 ** 9 or lst[-1] % 2 == 1:
	lst.append(lst[-1] + i)
	i += 1
for i in range(int(input())):
	(a, b) = map(int, input().split())
	diff = abs(b - a)
	k = bisect_left(lst, diff)
	while (lst[k] - diff) % 2 != 0:
		k += 1
	print(k)


from math import sqrt
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = abs(b - a)
	n = int((-1 + sqrt(8 * x + 1)) / 2)
	s = n * (n + 1) // 2
	if s == x:
		print(n)
	elif (s + n + 1 - x) % 2 == 0:
		print(n + 1)
	elif (s + 2 * n + 3 - x) % 2 == 0:
		print(n + 2)
	else:
		print(n + 3)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(a, b) = LI()
		s = abs(a - b)
		t = 0
		i = 0
		while 1:
			t += i
			if t >= s and (t - s) % 2 == 0:
				rr.append(i)
				break
			i += 1
	return JA(rr, '\n')
print(main())


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input().strip()
t = I()
for i in range(0, t):
	(a, b) = li()
	d = abs(a - b)
	s = 0
	i = 1
	ans = 0
	while s < d:
		s = s + i
		i += 1
		ans += 1
	if s == d:
		print(ans)
	else:
		while (d - s) % 2:
			s = s + i
			i += 1
		print(i - 1)