#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
long long abs(long long);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, long long *, ...);
main() {
  long long s, i, j, k, sum, n, m, all;
  scanf("%lld", &all);
  for (s = 0; s < all; s++) {
    k = 0;
    scanf("%lld%lld", &m, &n);
    sum = abs(m - n);
    i = 1;
    j = 0;
    while (sum > 0) {
      sum -= i;
      k++;
      if (j)
        i++;
      j = !j;
    }
    printf("%lld\n", k);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebe(%rip),%rdi
lea    -0x48(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x48(%rbp),%rax
jge    121e <main+0xee>
movq   $0x0,-0x28(%rbp)
lea    0xe8a(%rip),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x40(%rbp),%rdi
sub    -0x38(%rbp),%rdi
call   1030 <abs@plt>
mov    %rax,-0x30(%rbp)
movq   $0x1,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x30(%rbp)
jle    11fd <main+0xcd>
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11e3 <main+0xb3>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x20(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    %rax,-0x20(%rbp)
jmp    11a6 <main+0x76>
mov    -0x28(%rbp),%rsi
lea    0xe01(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1159 <main+0x29>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xed0(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpq   $0x0,0x8(%rsp)
jle    11da <main+0xba>
lea    0xead(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x18(%rsp),%r12
lea    0xea5(%rip),%r13
xor    %ebx,%ebx
jmp    1185 <main+0x65>
nopl   0x0(%rax,%rax,1)
xor    %esi,%esi
mov    %r13,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    0x8(%rsp),%rbx
jge    11da <main+0xba>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%rcx
sub    0x18(%rsp),%rcx
je     1170 <main+0x50>
mov    %rcx,%rax
neg    %rax
cmovs  %rcx,%rax
mov    $0x1,%edx
xor    %esi,%esi
xor    %ecx,%ecx
mov    $0x1,%edi
nopl   0x0(%rax)
add    $0x1,%rsi
cmp    $0x1,%rcx
sbb    $0xffffffffffffffff,%rdi
xor    $0x1,%rcx
sub    %rdx,%rax
mov    %rdi,%rdx
jg     11c0 <main+0xa0>
jmp    1172 <main+0x52>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [9 x i8] c"%lld%lld\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %1
%10 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %9)
store i64 0, i64* %2
br label %11
11: ; preds = %44, %0
%12 = load i64, i64* %2
%13 = load i64, i64* %9
%14 = icmp slt i64 %12, %13
br i1 %14, label %15, label %47
15: ; preds = %11
store i64 0, i64* %5
%16 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64* %8, i64* %7)
%17 = load i64, i64* %8
%18 = load i64, i64* %7
%19 = sub nsw i64 %17, %18
%20 = call i64 @abs(i64 %19)
store i64 %20, i64* %6
store i64 1, i64* %3
store i64 0, i64* %4
br label %21
21: ; preds = %35, %15
%22 = load i64, i64* %6
%23 = icmp sgt i64 %22, 0
br i1 %23, label %24, label %41
24: ; preds = %21
%25 = load i64, i64* %3
%26 = load i64, i64* %6
%27 = sub nsw i64 %26, %25
store i64 %27, i64* %6
%28 = load i64, i64* %5
%29 = add nsw i64 %28, 1
store i64 %29, i64* %5
%30 = load i64, i64* %4
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %24
%33 = load i64, i64* %3
%34 = add nsw i64 %33, 1
store i64 %34, i64* %3
br label %35
35: ; preds = %32, %24
%36 = load i64, i64* %4
%37 = icmp ne i64 %36, 0
%38 = xor i1 %37, true
%39 = zext i1 %38 to i32
%40 = sext i32 %39 to i64
store i64 %40, i64* %4
br label %21
41: ; preds = %21
%42 = load i64, i64* %5
%43 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %42)
br label %44
44: ; preds = %41
%45 = load i64, i64* %2
%46 = add nsw i64 %45, 1
store i64 %46, i64* %2
br label %11
47: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [9 x i8] c"%lld%lld\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %3)
%8 = load i64, i64* %3
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %37
10: ; preds = %0, %31
%11 = phi i64 [ %34, %31 ], [ 0, %0 ]
%12 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %1)
%13 = load i64, i64* %2
%14 = load i64, i64* %1
%15 = sub nsw i64 %13, %14
%16 = icmp eq i64 %15, 0
br i1 %16, label %31, label %17
17: ; preds = %10
%18 = call i64 @llvm.abs.i64(i64 %15, i1 true)
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ %24, %19 ], [ %18, %17 ]
%21 = phi i64 [ %25, %19 ], [ 0, %17 ]
%22 = phi i64 [ %29, %19 ], [ 0, %17 ]
%23 = phi i64 [ %28, %19 ], [ 1, %17 ]
%24 = sub nsw i64 %20, %23
%25 = add nuw nsw i64 %21, 1
%26 = icmp ne i64 %22, 0
%27 = zext i1 %26 to i64
%28 = add nuw nsw i64 %23, %27
%29 = xor i64 %22, 1
%30 = icmp sgt i64 %24, 0
br i1 %30, label %19, label %31
31: ; preds = %19, %10
%32 = phi i64 [ 0, %10 ], [ %25, %19 ]
%33 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %32)
%34 = add nuw nsw i64 %11, 1
%35 = load i64, i64* %3
%36 = icmp slt i64 %34, %35
br i1 %36, label %10, label %37
37: ; preds = %31, %0
ret i32 0
}