/*
不找规律,打表,搜索,O(n)
*/
// include file
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <functional>
using namespace std;
// typedef
typedef __int64 LL;
//
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define Z(a,b) ((a)<<(b))
#define Y(a,b) ((a)>>(b))
const double eps = 1e-6;
const double INFf = 1e100;
const int INFi = 1000000000;
const LL INFll = (LL)1<<62;
const double Pi = acos(-1.0);
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T TMAX(T x,T y)
{
if(x>y) return x;
return y;
}
template<class T> inline T TMIN(T x,T y)
{
if(x<y) return x;
return y;
}
template<class T> inline T MMAX(T x,T y,T z)
{
return TMAX(TMAX(x,y),z);
}
template<class T> inline T MMIN(T x,T y,T z)
{
return TMIN(TMIN(x,y),z);
}
template<class T> inline void SWAP(T &x,T &y)
{
T t = x;
x = y;
y = t;
}
// code begin
int N,x,y;
LL dt[80000];
void Init()
{
dt[1] = 1;
dt[2] = 3;
for(int i=3;i<80000;i++)
dt[i] = i+dt[i-1];
//printf("%I64d\n",dt[79999]);
}
int main()
{
read;
write;
Init();
scanf("%d",&N);
while(N--)
{
scanf("%d %d",&x,&y);
if(x>y) SWAP(x,y);
int d = y-x;
if(d<=2)
{
printf("%d\n",d);
}
else
{
int t = d,l;
for(int i=1;;i++)
{
if(2*(dt[i]-i)+i>t) break;
l = i;
}
int ans = 2*(l-1)+1;
int re = d-2*(dt[l]-l)-l;
for(int i=l;i>0;i--)
{
ans += re/i;
re%=i;
if(re==0) break;
}
printf("%d\n",ans);
}
}
return 0;
}