#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#define db(a) \
cout << #a << " = " << a << endl
#define db2(a, b) \
cout << #a << " = " << a << " " << #b << " = " << b << endl
#define inf (1<<30)
#define foreach(it, m) \
for (typeof(m.begin()) it = m.begin(); it != m.end(); it++)
using namespace std;
int main() {
#ifdef dennisbot
freopen("in.in", "r", stdin);
//freopen("ou.out", "w", stdout);
#endif
int x, y;
int t;
scanf("%d", &t);
//db(t);
for (int i = 0; i < t; i++) {
scanf("%d%d", &x , &y);
//db2(x, y);
if (x == y) {
puts("0");
continue;
}
int n = (int)sqrt(y - x);
//db(n);
if (n * n == y - x)
n = 2 * n - 1;
else
if (n * (n + 1) < y - x) {
n = 2 * n + 1;
}
else n = 2 * n;
/*db2(x, y);
db(n);*/
printf("%d\n", n);
}
return 0;
}
a good explanation can be found hereAlgorithmist