#include
#include
using namespace std;
int main()
{
int testcase=0;
cin>>testcase;
while(testcase--)
{
long long a=0,b=0;
cin>>a>>b;
if (a==b) //if both are same
cout<<0<<endl;
else
{
int flag=0;
long long diff=llabs(a-b); //finding the diffrence between the numbers
long long length=0;
if(a>b)
length=a;
else
length=b;
for(long long i=1;i<length;i++)
{
if(diff==(i*(i+1))/2) // checking if the diffrence = sum of first i natural numbers
{ cout<<i<<endl; // if so then all the operation will be performed on the one of
the number whichever is smaller
flag=1;
break;}}
long long i=1,counter=0;
while(a!=b && flag==0) // if not so then operation will be performed on both the
nos. on alternate time.
{
if(a<b)
{
if((i%2)!=0)
a+=i;
else
b+=i;
i++;
counter++;
}
else
{
if((i%2)!=0)
b+=i;
else
a+=i;
i++;
counter++;
}
}
if(flag==0)
{
cout<<counter<<endl;
flag=1;
}
}
}
return 0;
}