//Chaos///

#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#if DEBUG && !ONLINE_JUDGE

    #define debug(args...)     (Debugger()) , args
    //istringstream ss1(tmp11);
    class Debugger
    {
        public:
        Debugger(const std::string& _separator = ", ") :
        first(true), separator(_separator){}

        template<typename ObjectType>
        Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

    template <typename T1, typename T2>
    inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
    {
        return os << "(" << p.first << ", " << p.second << ")";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
    {
        bool first = true;
        os << "[";
        for(unsigned int i = 0; i < v.size(); i++)
        {
            if(!first)
                os << ", ";
            os << v[i];
            first = false;
        }
        return os << "]";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii;
            first = false;
        }
        return os << "]";
    }

    template<typename T1, typename T2>
    inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii ;
            first = false;
        }
        return os << "]";
    }
#else
    #define debug(args...)
#endif
#define mod 1000000007
#define ok order_of_key
#define fo find_by_order
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repp(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define newl cout<<'\n'
#define inf 1000000000
#define repaa(i,a) for(auto i=a.begin();i!=a.end();++i)
#define pb push_back
#define test cout<<"test"<<endl
#define start int tt;cin>>tt;while(tt--)
#define tc int tt;tt=read();while(tt--)
#define nl "\n"
#define startk int tt;cin>>tt;for(int kk=1;kk<=tt;kk++)
#define mem(v,i) memset(v,i,sizeof(v))//Use mem(v,60) to initialize with 10^9
#define all(x) x.begin(), x.end()
#define inf1 1e18
#define repa(i,a) for (auto i : a)
#define X first
#define Y second
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define dec(v) sort(v.begin(),v.end(),greater<int>());
#define in(a,n) repp(jjj,n)cin>>a[jjj];
#define re(a,n) repp(jjj,n)a[jjj]=read();
#define retree(a,m) repp(i,m){int tmp1=read()-1,tmp2=read()-1;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define intree(a,m) repp(i,m){int tmp1,tmp2;cin>>tmp1>>tmp2;tmp1--,tmp2--;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define ins insert
#define er erase
#define sz(a) (int)(a.size())
#define big cpp_int
#define ll128 int128_t //Write (ll128) when using this type.
#define print(x,n,k) repp(i,n){repp(j,k)cout<<x[i][j]<<"  ";newl;}
#define mt make_tuple
#define eb emplace_back
#define p_q priority_queue
#define time cerr << 1.0 * clock()
#define bp(i) __builtin_popcountll(i)
#define precision(x) cout << fixed << setprecision(x);
typedef long double ld;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pair<int,int>> vip;
typedef vector<pair<int,ll>> vil; // use for Dijkstra wih long weights
typedef vector<pair<ll,ll>> vll;
typedef pair<int, int> ip;
typedef pair<int, ll> il;
typedef pair<ll, ll> pll;
typedef tuple<int,int,int> state;
typedef tuple<ll,int,int> statel;
#ifdef Fading
#define gc getchar
#endif
#ifndef Fading
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
#endif
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
template<typename T>
T Min(T v) {
  return v;
}
template<typename T, typename... Args>
T Min(T first, Args... args) {
  return min(first , Min(args...));
}
template<typename T>
T Max(T v) {
  return v;
}
template<typename T, typename... Args>
T Max(T first, Args... args) {
  return max(first , Max(args...));
}
template<typename T>
T mult(T v) {
  return v;
}
template<typename T, typename... Args>
T mult(T first, Args... args) {
  return mult((first * mult(args...))%mod);
}
template<typename T>
T addr(T v) {
  return v;
}
template<typename T, typename... Args>
T addr(T first, Args... args) {
  return addr((first + addr(args...))%mod);
}
template<class T> inline bool remax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline bool remin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class A, class B>
void add(A &a, B b)//adds in a. Does not return anything.
{
    a += b;
    if (a < 0LL) a += mod;
    if (a >= mod) a -= mod;
}
template<class A, class B>
void mul(A &a, B b)//adds in a. Does not return anything.
{
    a=(a*b)%mod;
}
inline int to_i(char c)
{
    return c - 'a';
}
/*
int n;
const int NNNN=1000*1000+5;
ll BITTree1[NNNN],BITTree2[NNNN];
ll getSum(ll BITree[],int index){
    ll sum = 0;
    index++;
    while (index>0){
        sum += BITree[index];
        index -= index & (-index);
    }
    return sum;
}
void updateBIT(ll BITree[],int index,ll val){
    index++;
    while (index <= n){
        BITree[index] += val;
        index += index & (-index);
    }
}
int sum(int x){
    return getSum(BITTree1,x)*x-getSum(BITTree2,x);
}
void updateRange(int l,int r,int val){
    updateBIT(BITTree1,l,val);
    updateBIT(BITTree1,r+1,-val);
    updateBIT(BITTree2,l,val*(l-1));
    updateBIT(BITTree2,r+1,-val*r);
}
ll rangeSum(int l, int r){
    return sum(r)-sum(l-1);
}
*/
/*
const int NN=2*1000*100+4;
int dsu[NN],sub[NN];
void pre(){
repp(i,NN)dsu[i]=i,sub[i]=1;
}
int root(int a){
    while(dsu[a]!=a){
        dsu[a]=dsu[dsu[a]];
        a=dsu[a];
    }
    return a;
}
void uni(int a,int b){
    int _a=root(a);
    int _b=root(b);
    if(_a==_b)return ;
    if(sub[_a]>sub[_b]){
        dsu[_b]=dsu[_a];
        sub[_a]+=sub[_b];
    }
    else {
        dsu[_a]=dsu[_b];
        sub[_b]+=sub[_a];
    }
}
*/
/*
const int LOGN=19,NNN=1000*1000+5;
int DP[LOGN][NN],level[NNN];
void dfs0(int u)
{
	for(auto it=a[u].begin();it!=a[u].end();it++)
		if(*it!=DP[0][u])
		{
			DP[0][*it]=u;
			level[*it]=level[u]+1;
			dfs0(*it);
		}
}
void preprocess()
{
	dfs0(0);
	for(int i=1;i<LOGN;i++)
		for(int j=0;j<n;j++)
			DP[i][j] = DP[i-1][DP[i-1][j]];
}
int lca(int a,int b)
{
	if(level[a]>level[b])swap(a,b);
	int d = level[b]-level[a];
	for(int i=0;i<LOGN;i++)
		if(d&(1<<i))
			b=DP[i][b];
	if(a==b)return a;
	for(int i=LOGN-1;i>=0;i--)
		if(DP[i][a]!=DP[i][b])
			a=DP[i][a],b=DP[i][b];
	return DP[0][a];
}
*/
/*
ll poww(ll a, ll b)
{
    ll val = 1;
    a %= mod;
    while (b > 0)
    {
        if (b % 2) val = mult(a, val);
        a = mult(a, a);
        b >>= 1;
    }
    return val % mod;
}
ll inv(ll a)
{
    return poww(a , mod - 2);
}
*/
/*
const int jj=2e5+5;
ll fac[jj];
void pre(){
    fac[0] = 1;
    for (int i=1 ; i<jj; i++)
    fac[i] = fac[i-1]*i%mod;
}
ll nc(int n,int r)
{
   if (r==0)
      return 1;
   return (fac[n]*inv(fac[r])%mod*inv(fac[n-r])%mod)%mod;
}
*/
/*
string to_str(ll a){
    string mystring;
    stringstream mystream;
    mystream << a;
    mystring = mystream.str();
    return mystring;
}
*/
/*
bool iscomp[100000];
vi primes;
void sieve(int n){
    for(int i=2;i<=n;++i){
        if(!iscomp[i]){
            primes.eb(i);
            for(int j=i*i;j<=n;j+=i)iscomp[j]=1;
        }
    }
}
*/
/*
vl prime(ll n){
    vl v;
    for(int i=2;i*i<=n;++i){
        if(n%i==0)v.eb(i);
        while(n%i==0)n/=i;
    }
    if(n!=1)v.eb(n);
    return v;
}
*/
/*
ll gcd1(ll a, ll b, ll &x, ll &y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd1(b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
bool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g) {
    g = gcd1(abs1(a), abs1(b), x0, y0);
    if (c % g!=0) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}
*/
/*
int cc(ll x){
    int ans=0;
    while(x){if(x&1LL)ans++;x/=2;}
    return ans;
}
*/
// Treap
// auto cmp = [](ip a, ip b){return a.X==b.X?a.Y>b.Y:a.X>b.X;};
 //   set<ip,decltype(cmp)> s(cmp);

//-----------------------------------------------------end--------------------------------------//

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    tc{
        ll a=read(),b=read();
        ll diff = abs(a-b);
        a = max(a,b);
        b = a-diff;
        ll sum = 0;
        int add = 1;
        while(sum < diff)sum+=add++;
        cout<<add + (sum==diff?-1:0)<< nl;
    }
}


//Chaos///

#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#if DEBUG && !ONLINE_JUDGE

    #define debug(args...)     (Debugger()) , args
    //istringstream ss1(tmp11);
    class Debugger
    {
        public:
        Debugger(const std::string& _separator = ", ") :
        first(true), separator(_separator){}

        template<typename ObjectType>
        Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

    template <typename T1, typename T2>
    inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
    {
        return os << "(" << p.first << ", " << p.second << ")";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
    {
        bool first = true;
        os << "[";
        for(unsigned int i = 0; i < v.size(); i++)
        {
            if(!first)
                os << ", ";
            os << v[i];
            first = false;
        }
        return os << "]";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii;
            first = false;
        }
        return os << "]";
    }

    template<typename T1, typename T2>
    inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii ;
            first = false;
        }
        return os << "]";
    }
#else
    #define debug(args...)
#endif
#define mod 1000000007
#define ok order_of_key
#define fo find_by_order
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repp(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define newl cout<<'\n'
#define inf 1000000000
#define repaa(i,a) for(auto i=a.begin();i!=a.end();++i)
#define pb push_back
#define test cout<<"test"<<endl
#define start int tt;cin>>tt;while(tt--)
#define tc int tt;tt=read();while(tt--)
#define nl "\n"
#define startk int tt;cin>>tt;for(int kk=1;kk<=tt;kk++)
#define mem(v,i) memset(v,i,sizeof(v))//Use mem(v,60) to initialize with 10^9
#define all(x) x.begin(), x.end()
#define inf1 1e18
#define repa(i,a) for (auto i : a)
#define X first
#define Y second
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define dec(v) sort(v.begin(),v.end(),greater<int>());
#define in(a,n) repp(jjj,n)cin>>a[jjj];
#define re(a,n) repp(jjj,n)a[jjj]=read();
#define retree(a,m) repp(i,m){int tmp1=read()-1,tmp2=read()-1;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define intree(a,m) repp(i,m){int tmp1,tmp2;cin>>tmp1>>tmp2;tmp1--,tmp2--;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define ins insert
#define er erase
#define sz(a) (int)(a.size())
#define big cpp_int
#define ll128 int128_t //Write (ll128) when using this type.
#define print(x,n,k) repp(i,n){repp(j,k)cout<<x[i][j]<<"  ";newl;}
#define mt make_tuple
#define eb emplace_back
#define p_q priority_queue
#define time cerr << 1.0 * clock()
#define bp(i) __builtin_popcountll(i)
#define precision(x) cout << fixed << setprecision(x);
typedef long double ld;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pair<int,int>> vip;
typedef vector<pair<int,ll>> vil; // use for Dijkstra wih long weights
typedef vector<pair<ll,ll>> vll;
typedef pair<int, int> ip;
typedef pair<int, ll> il;
typedef pair<ll, ll> pll;
typedef tuple<int,int,int> state;
typedef tuple<ll,int,int> statel;
#ifdef Fading
#define gc getchar
#endif
#ifndef Fading
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
#endif
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
template<typename T>
T Min(T v) {
  return v;
}
template<typename T, typename... Args>
T Min(T first, Args... args) {
  return min(first , Min(args...));
}
template<typename T>
T Max(T v) {
  return v;
}
template<typename T, typename... Args>
T Max(T first, Args... args) {
  return max(first , Max(args...));
}
template<typename T>
T mult(T v) {
  return v;
}
template<typename T, typename... Args>
T mult(T first, Args... args) {
  return mult((first * mult(args...))%mod);
}
template<typename T>
T addr(T v) {
  return v;
}
template<typename T, typename... Args>
T addr(T first, Args... args) {
  return addr((first + addr(args...))%mod);
}
template<class T> inline bool remax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline bool remin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class A, class B>
void add(A &a, B b)//adds in a. Does not return anything.
{
    a += b;
    if (a < 0LL) a += mod;
    if (a >= mod) a -= mod;
}
template<class A, class B>
void mul(A &a, B b)//adds in a. Does not return anything.
{
    a=(a*b)%mod;
}
inline int to_i(char c)
{
    return c - 'a';
}
/*
int n;
const int NNNN=1000*1000+5;
ll BITTree1[NNNN],BITTree2[NNNN];
ll getSum(ll BITree[],int index){
    ll sum = 0;
    index++;
    while (index>0){
        sum += BITree[index];
        index -= index & (-index);
    }
    return sum;
}
void updateBIT(ll BITree[],int index,ll val){
    index++;
    while (index <= n){
        BITree[index] += val;
        index += index & (-index);
    }
}
int sum(int x){
    return getSum(BITTree1,x)*x-getSum(BITTree2,x);
}
void updateRange(int l,int r,int val){
    updateBIT(BITTree1,l,val);
    updateBIT(BITTree1,r+1,-val);
    updateBIT(BITTree2,l,val*(l-1));
    updateBIT(BITTree2,r+1,-val*r);
}
ll rangeSum(int l, int r){
    return sum(r)-sum(l-1);
}
*/
/*
const int NN=2*1000*100+4;
int dsu[NN],sub[NN];
void pre(){
repp(i,NN)dsu[i]=i,sub[i]=1;
}
int root(int a){
    while(dsu[a]!=a){
        dsu[a]=dsu[dsu[a]];
        a=dsu[a];
    }
    return a;
}
void uni(int a,int b){
    int _a=root(a);
    int _b=root(b);
    if(_a==_b)return ;
    if(sub[_a]>sub[_b]){
        dsu[_b]=dsu[_a];
        sub[_a]+=sub[_b];
    }
    else {
        dsu[_a]=dsu[_b];
        sub[_b]+=sub[_a];
    }
}
*/
/*
const int LOGN=19,NNN=1000*1000+5;
int DP[LOGN][NN],level[NNN];
void dfs0(int u)
{
	for(auto it=a[u].begin();it!=a[u].end();it++)
		if(*it!=DP[0][u])
		{
			DP[0][*it]=u;
			level[*it]=level[u]+1;
			dfs0(*it);
		}
}
void preprocess()
{
	dfs0(0);
	for(int i=1;i<LOGN;i++)
		for(int j=0;j<n;j++)
			DP[i][j] = DP[i-1][DP[i-1][j]];
}
int lca(int a,int b)
{
	if(level[a]>level[b])swap(a,b);
	int d = level[b]-level[a];
	for(int i=0;i<LOGN;i++)
		if(d&(1<<i))
			b=DP[i][b];
	if(a==b)return a;
	for(int i=LOGN-1;i>=0;i--)
		if(DP[i][a]!=DP[i][b])
			a=DP[i][a],b=DP[i][b];
	return DP[0][a];
}
*/
/*
ll poww(ll a, ll b)
{
    ll val = 1;
    a %= mod;
    while (b > 0)
    {
        if (b % 2) val = mult(a, val);
        a = mult(a, a);
        b >>= 1;
    }
    return val % mod;
}
ll inv(ll a)
{
    return poww(a , mod - 2);
}
*/
/*
const int jj=2e5+5;
ll fac[jj];
void pre(){
    fac[0] = 1;
    for (int i=1 ; i<jj; i++)
    fac[i] = fac[i-1]*i%mod;
}
ll nc(int n,int r)
{
   if (r==0)
      return 1;
   return (fac[n]*inv(fac[r])%mod*inv(fac[n-r])%mod)%mod;
}
*/
/*
string to_str(ll a){
    string mystring;
    stringstream mystream;
    mystream << a;
    mystring = mystream.str();
    return mystring;
}
*/
/*
bool iscomp[100000];
vi primes;
void sieve(int n){
    for(int i=2;i<=n;++i){
        if(!iscomp[i]){
            primes.eb(i);
            for(int j=i*i;j<=n;j+=i)iscomp[j]=1;
        }
    }
}
*/
/*
vl prime(ll n){
    vl v;
    for(int i=2;i*i<=n;++i){
        if(n%i==0)v.eb(i);
        while(n%i==0)n/=i;
    }
    if(n!=1)v.eb(n);
    return v;
}
*/
/*
ll gcd1(ll a, ll b, ll &x, ll &y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd1(b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
bool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g) {
    g = gcd1(abs1(a), abs1(b), x0, y0);
    if (c % g!=0) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}
*/
/*
int cc(ll x){
    int ans=0;
    while(x){if(x&1LL)ans++;x/=2;}
    return ans;
}
*/
// Treap
// auto cmp = [](ip a, ip b){return a.X==b.X?a.Y>b.Y:a.X>b.X;};
 //   set<ip,decltype(cmp)> s(cmp);

//-----------------------------------------------------end--------------------------------------//

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    tc{
        ll a=read(),b=read();
        ll diff = abs(a-b);
        a = max(a,b);
        b = a-diff;
        ll sum = 0;
        int add = 1;
        while(sum < diff){sum+=add++;debug(sum,add);}
        if((sum - diff)%2==0)cout<<add-1;
        else cout<<add;
        newl;
    }
}


//Chaos///

#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#if DEBUG && !ONLINE_JUDGE

    #define debug(args...)     (Debugger()) , args
    //istringstream ss1(tmp11);
    class Debugger
    {
        public:
        Debugger(const std::string& _separator = ", ") :
        first(true), separator(_separator){}

        template<typename ObjectType>
        Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

    template <typename T1, typename T2>
    inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
    {
        return os << "(" << p.first << ", " << p.second << ")";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
    {
        bool first = true;
        os << "[";
        for(unsigned int i = 0; i < v.size(); i++)
        {
            if(!first)
                os << ", ";
            os << v[i];
            first = false;
        }
        return os << "]";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii;
            first = false;
        }
        return os << "]";
    }

    template<typename T1, typename T2>
    inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii ;
            first = false;
        }
        return os << "]";
    }
#else
    #define debug(args...)
#endif
#define mod 1000000007
#define ok order_of_key
#define fo find_by_order
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repp(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define newl cout<<'\n'
#define inf 1000000000
#define repaa(i,a) for(auto i=a.begin();i!=a.end();++i)
#define pb push_back
#define test cout<<"test"<<endl
#define start int tt;cin>>tt;while(tt--)
#define tc int tt;tt=read();while(tt--)
#define nl "\n"
#define startk int tt;cin>>tt;for(int kk=1;kk<=tt;kk++)
#define mem(v,i) memset(v,i,sizeof(v))//Use mem(v,60) to initialize with 10^9
#define all(x) x.begin(), x.end()
#define inf1 1e18
#define repa(i,a) for (auto i : a)
#define X first
#define Y second
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define dec(v) sort(v.begin(),v.end(),greater<int>());
#define in(a,n) repp(jjj,n)cin>>a[jjj];
#define re(a,n) repp(jjj,n)a[jjj]=read();
#define retree(a,m) repp(i,m){int tmp1=read()-1,tmp2=read()-1;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define intree(a,m) repp(i,m){int tmp1,tmp2;cin>>tmp1>>tmp2;tmp1--,tmp2--;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define ins insert
#define er erase
#define sz(a) (int)(a.size())
#define big cpp_int
#define ll128 int128_t //Write (ll128) when using this type.
#define print(x,n,k) repp(i,n){repp(j,k)cout<<x[i][j]<<"  ";newl;}
#define mt make_tuple
#define eb emplace_back
#define p_q priority_queue
#define time cerr << 1.0 * clock()
#define bp(i) __builtin_popcountll(i)
#define precision(x) cout << fixed << setprecision(x);
typedef long double ld;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pair<int,int>> vip;
typedef vector<pair<int,ll>> vil; // use for Dijkstra wih long weights
typedef vector<pair<ll,ll>> vll;
typedef pair<int, int> ip;
typedef pair<int, ll> il;
typedef pair<ll, ll> pll;
typedef tuple<int,int,int> state;
typedef tuple<ll,int,int> statel;
#ifdef Fading
#define gc getchar
#endif
#ifndef Fading
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
#endif
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
template<typename T>
T Min(T v) {
  return v;
}
template<typename T, typename... Args>
T Min(T first, Args... args) {
  return min(first , Min(args...));
}
template<typename T>
T Max(T v) {
  return v;
}
template<typename T, typename... Args>
T Max(T first, Args... args) {
  return max(first , Max(args...));
}
template<typename T>
T mult(T v) {
  return v;
}
template<typename T, typename... Args>
T mult(T first, Args... args) {
  return mult((first * mult(args...))%mod);
}
template<typename T>
T addr(T v) {
  return v;
}
template<typename T, typename... Args>
T addr(T first, Args... args) {
  return addr((first + addr(args...))%mod);
}
template<class T> inline bool remax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline bool remin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class A, class B>
void add(A &a, B b)//adds in a. Does not return anything.
{
    a += b;
    if (a < 0LL) a += mod;
    if (a >= mod) a -= mod;
}
template<class A, class B>
void mul(A &a, B b)//adds in a. Does not return anything.
{
    a=(a*b)%mod;
}
inline int to_i(char c)
{
    return c - 'a';
}
/*
int n;
const int NNNN=1000*1000+5;
ll BITTree1[NNNN],BITTree2[NNNN];
ll getSum(ll BITree[],int index){
    ll sum = 0;
    index++;
    while (index>0){
        sum += BITree[index];
        index -= index & (-index);
    }
    return sum;
}
void updateBIT(ll BITree[],int index,ll val){
    index++;
    while (index <= n){
        BITree[index] += val;
        index += index & (-index);
    }
}
int sum(int x){
    return getSum(BITTree1,x)*x-getSum(BITTree2,x);
}
void updateRange(int l,int r,int val){
    updateBIT(BITTree1,l,val);
    updateBIT(BITTree1,r+1,-val);
    updateBIT(BITTree2,l,val*(l-1));
    updateBIT(BITTree2,r+1,-val*r);
}
ll rangeSum(int l, int r){
    return sum(r)-sum(l-1);
}
*/
/*
const int NN=2*1000*100+4;
int dsu[NN],sub[NN];
void pre(){
repp(i,NN)dsu[i]=i,sub[i]=1;
}
int root(int a){
    while(dsu[a]!=a){
        dsu[a]=dsu[dsu[a]];
        a=dsu[a];
    }
    return a;
}
void uni(int a,int b){
    int _a=root(a);
    int _b=root(b);
    if(_a==_b)return ;
    if(sub[_a]>sub[_b]){
        dsu[_b]=dsu[_a];
        sub[_a]+=sub[_b];
    }
    else {
        dsu[_a]=dsu[_b];
        sub[_b]+=sub[_a];
    }
}
*/
/*
const int LOGN=19,NNN=1000*1000+5;
int DP[LOGN][NN],level[NNN];
void dfs0(int u)
{
	for(auto it=a[u].begin();it!=a[u].end();it++)
		if(*it!=DP[0][u])
		{
			DP[0][*it]=u;
			level[*it]=level[u]+1;
			dfs0(*it);
		}
}
void preprocess()
{
	dfs0(0);
	for(int i=1;i<LOGN;i++)
		for(int j=0;j<n;j++)
			DP[i][j] = DP[i-1][DP[i-1][j]];
}
int lca(int a,int b)
{
	if(level[a]>level[b])swap(a,b);
	int d = level[b]-level[a];
	for(int i=0;i<LOGN;i++)
		if(d&(1<<i))
			b=DP[i][b];
	if(a==b)return a;
	for(int i=LOGN-1;i>=0;i--)
		if(DP[i][a]!=DP[i][b])
			a=DP[i][a],b=DP[i][b];
	return DP[0][a];
}
*/
/*
ll poww(ll a, ll b)
{
    ll val = 1;
    a %= mod;
    while (b > 0)
    {
        if (b % 2) val = mult(a, val);
        a = mult(a, a);
        b >>= 1;
    }
    return val % mod;
}
ll inv(ll a)
{
    return poww(a , mod - 2);
}
*/
/*
const int jj=2e5+5;
ll fac[jj];
void pre(){
    fac[0] = 1;
    for (int i=1 ; i<jj; i++)
    fac[i] = fac[i-1]*i%mod;
}
ll nc(int n,int r)
{
   if (r==0)
      return 1;
   return (fac[n]*inv(fac[r])%mod*inv(fac[n-r])%mod)%mod;
}
*/
/*
string to_str(ll a){
    string mystring;
    stringstream mystream;
    mystream << a;
    mystring = mystream.str();
    return mystring;
}
*/
/*
bool iscomp[100000];
vi primes;
void sieve(int n){
    for(int i=2;i<=n;++i){
        if(!iscomp[i]){
            primes.eb(i);
            for(int j=i*i;j<=n;j+=i)iscomp[j]=1;
        }
    }
}
*/
/*
vl prime(ll n){
    vl v;
    for(int i=2;i*i<=n;++i){
        if(n%i==0)v.eb(i);
        while(n%i==0)n/=i;
    }
    if(n!=1)v.eb(n);
    return v;
}
*/
/*
ll gcd1(ll a, ll b, ll &x, ll &y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd1(b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
bool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g) {
    g = gcd1(abs1(a), abs1(b), x0, y0);
    if (c % g!=0) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}
*/
/*
int cc(ll x){
    int ans=0;
    while(x){if(x&1LL)ans++;x/=2;}
    return ans;
}
*/
// Treap
// auto cmp = [](ip a, ip b){return a.X==b.X?a.Y>b.Y:a.X>b.X;};
 //   set<ip,decltype(cmp)> s(cmp);

//-----------------------------------------------------end--------------------------------------//

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    tc{
        ll a=read(),b=read();
        ll diff = abs(a-b);
        a = max(a,b);
        b = a-diff;
        ll sum = 0;
        int add = 1;
        while(sum < diff){sum+=add++;debug(sum,add);}
        int tmp = 0;
        bool fl = 1;
        while(tmp <add){debug(sum,tmp,diff);
            if(sum-2*tmp==diff){fl=0;break;}
            tmp++;
        }
        if(!fl)cout<<add-1;
        else cout<<add;
        newl;
    }
}


//Chaos///

#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#if DEBUG && !ONLINE_JUDGE

    #define debug(args...)     (Debugger()) , args
    //istringstream ss1(tmp11);
    class Debugger
    {
        public:
        Debugger(const std::string& _separator = ", ") :
        first(true), separator(_separator){}

        template<typename ObjectType>
        Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

    template <typename T1, typename T2>
    inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
    {
        return os << "(" << p.first << ", " << p.second << ")";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
    {
        bool first = true;
        os << "[";
        for(unsigned int i = 0; i < v.size(); i++)
        {
            if(!first)
                os << ", ";
            os << v[i];
            first = false;
        }
        return os << "]";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii;
            first = false;
        }
        return os << "]";
    }

    template<typename T1, typename T2>
    inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii ;
            first = false;
        }
        return os << "]";
    }
#else
    #define debug(args...)
#endif
#define mod 1000000007
#define ok order_of_key
#define fo find_by_order
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repp(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define newl cout<<'\n'
#define inf 1000000000
#define repaa(i,a) for(auto i=a.begin();i!=a.end();++i)
#define pb push_back
#define test cout<<"test"<<endl
#define start int tt;cin>>tt;while(tt--)
#define tc int tt;tt=read();while(tt--)
#define nl "\n"
#define startk int tt;cin>>tt;for(int kk=1;kk<=tt;kk++)
#define mem(v,i) memset(v,i,sizeof(v))//Use mem(v,60) to initialize with 10^9
#define all(x) x.begin(), x.end()
#define inf1 1e18
#define repa(i,a) for (auto i : a)
#define X first
#define Y second
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define dec(v) sort(v.begin(),v.end(),greater<int>());
#define in(a,n) repp(jjj,n)cin>>a[jjj];
#define re(a,n) repp(jjj,n)a[jjj]=read();
#define retree(a,m) repp(i,m){int tmp1=read()-1,tmp2=read()-1;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define intree(a,m) repp(i,m){int tmp1,tmp2;cin>>tmp1>>tmp2;tmp1--,tmp2--;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define ins insert
#define er erase
#define sz(a) (int)(a.size())
#define big cpp_int
#define ll128 int128_t //Write (ll128) when using this type.
#define print(x,n,k) repp(i,n){repp(j,k)cout<<x[i][j]<<"  ";newl;}
#define mt make_tuple
#define eb emplace_back
#define p_q priority_queue
#define time cerr << 1.0 * clock()
#define bp(i) __builtin_popcountll(i)
#define precision(x) cout << fixed << setprecision(x);
typedef long double ld;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pair<int,int>> vip;
typedef vector<pair<int,ll>> vil; // use for Dijkstra wih long weights
typedef vector<pair<ll,ll>> vll;
typedef pair<int, int> ip;
typedef pair<int, ll> il;
typedef pair<ll, ll> pll;
typedef tuple<int,int,int> state;
typedef tuple<ll,int,int> statel;
#ifdef Fading
#define gc getchar
#endif
#ifndef Fading
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
#endif
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
template<typename T>
T Min(T v) {
  return v;
}
template<typename T, typename... Args>
T Min(T first, Args... args) {
  return min(first , Min(args...));
}
template<typename T>
T Max(T v) {
  return v;
}
template<typename T, typename... Args>
T Max(T first, Args... args) {
  return max(first , Max(args...));
}
template<typename T>
T mult(T v) {
  return v;
}
template<typename T, typename... Args>
T mult(T first, Args... args) {
  return mult((first * mult(args...))%mod);
}
template<typename T>
T addr(T v) {
  return v;
}
template<typename T, typename... Args>
T addr(T first, Args... args) {
  return addr((first + addr(args...))%mod);
}
template<class T> inline bool remax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline bool remin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class A, class B>
void add(A &a, B b)//adds in a. Does not return anything.
{
    a += b;
    if (a < 0LL) a += mod;
    if (a >= mod) a -= mod;
}
template<class A, class B>
void mul(A &a, B b)//adds in a. Does not return anything.
{
    a=(a*b)%mod;
}
inline int to_i(char c)
{
    return c - 'a';
}
/*
int n;
const int NNNN=1000*1000+5;
ll BITTree1[NNNN],BITTree2[NNNN];
ll getSum(ll BITree[],int index){
    ll sum = 0;
    index++;
    while (index>0){
        sum += BITree[index];
        index -= index & (-index);
    }
    return sum;
}
void updateBIT(ll BITree[],int index,ll val){
    index++;
    while (index <= n){
        BITree[index] += val;
        index += index & (-index);
    }
}
int sum(int x){
    return getSum(BITTree1,x)*x-getSum(BITTree2,x);
}
void updateRange(int l,int r,int val){
    updateBIT(BITTree1,l,val);
    updateBIT(BITTree1,r+1,-val);
    updateBIT(BITTree2,l,val*(l-1));
    updateBIT(BITTree2,r+1,-val*r);
}
ll rangeSum(int l, int r){
    return sum(r)-sum(l-1);
}
*/
/*
const int NN=2*1000*100+4;
int dsu[NN],sub[NN];
void pre(){
repp(i,NN)dsu[i]=i,sub[i]=1;
}
int root(int a){
    while(dsu[a]!=a){
        dsu[a]=dsu[dsu[a]];
        a=dsu[a];
    }
    return a;
}
void uni(int a,int b){
    int _a=root(a);
    int _b=root(b);
    if(_a==_b)return ;
    if(sub[_a]>sub[_b]){
        dsu[_b]=dsu[_a];
        sub[_a]+=sub[_b];
    }
    else {
        dsu[_a]=dsu[_b];
        sub[_b]+=sub[_a];
    }
}
*/
/*
const int LOGN=19,NNN=1000*1000+5;
int DP[LOGN][NN],level[NNN];
void dfs0(int u)
{
	for(auto it=a[u].begin();it!=a[u].end();it++)
		if(*it!=DP[0][u])
		{
			DP[0][*it]=u;
			level[*it]=level[u]+1;
			dfs0(*it);
		}
}
void preprocess()
{
	dfs0(0);
	for(int i=1;i<LOGN;i++)
		for(int j=0;j<n;j++)
			DP[i][j] = DP[i-1][DP[i-1][j]];
}
int lca(int a,int b)
{
	if(level[a]>level[b])swap(a,b);
	int d = level[b]-level[a];
	for(int i=0;i<LOGN;i++)
		if(d&(1<<i))
			b=DP[i][b];
	if(a==b)return a;
	for(int i=LOGN-1;i>=0;i--)
		if(DP[i][a]!=DP[i][b])
			a=DP[i][a],b=DP[i][b];
	return DP[0][a];
}
*/
/*
ll poww(ll a, ll b)
{
    ll val = 1;
    a %= mod;
    while (b > 0)
    {
        if (b % 2) val = mult(a, val);
        a = mult(a, a);
        b >>= 1;
    }
    return val % mod;
}
ll inv(ll a)
{
    return poww(a , mod - 2);
}
*/
/*
const int jj=2e5+5;
ll fac[jj];
void pre(){
    fac[0] = 1;
    for (int i=1 ; i<jj; i++)
    fac[i] = fac[i-1]*i%mod;
}
ll nc(int n,int r)
{
   if (r==0)
      return 1;
   return (fac[n]*inv(fac[r])%mod*inv(fac[n-r])%mod)%mod;
}
*/
/*
string to_str(ll a){
    string mystring;
    stringstream mystream;
    mystream << a;
    mystring = mystream.str();
    return mystring;
}
*/
/*
bool iscomp[100000];
vi primes;
void sieve(int n){
    for(int i=2;i<=n;++i){
        if(!iscomp[i]){
            primes.eb(i);
            for(int j=i*i;j<=n;j+=i)iscomp[j]=1;
        }
    }
}
*/
/*
vl prime(ll n){
    vl v;
    for(int i=2;i*i<=n;++i){
        if(n%i==0)v.eb(i);
        while(n%i==0)n/=i;
    }
    if(n!=1)v.eb(n);
    return v;
}
*/
/*
ll gcd1(ll a, ll b, ll &x, ll &y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd1(b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
bool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g) {
    g = gcd1(abs1(a), abs1(b), x0, y0);
    if (c % g!=0) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}
*/
/*
int cc(ll x){
    int ans=0;
    while(x){if(x&1LL)ans++;x/=2;}
    return ans;
}
*/
// Treap
// auto cmp = [](ip a, ip b){return a.X==b.X?a.Y>b.Y:a.X>b.X;};
 //   set<ip,decltype(cmp)> s(cmp);

//-----------------------------------------------------end--------------------------------------//

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    tc{
        ll a=read(),b=read();
        ll diff = abs(a-b);
        a = max(a,b);
        b = a-diff;
        ll sum = 0;
        int add = 1;
        while(sum < diff){sum+=add++;debug(sum,add);}
        int tmp = 0;
        bool fl = 1;
        while(tmp <add){
            if(sum-tmp==diff){fl=0;break;}
            tmp++;
        }
        if(!fl)cout<<add-1;
        else cout<<add;
        newl;
    }
}


//Chaos///

#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#if DEBUG && !ONLINE_JUDGE

    #define debug(args...)     (Debugger()) , args
    //istringstream ss1(tmp11);
    class Debugger
    {
        public:
        Debugger(const std::string& _separator = ", ") :
        first(true), separator(_separator){}

        template<typename ObjectType>
        Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

    template <typename T1, typename T2>
    inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
    {
        return os << "(" << p.first << ", " << p.second << ")";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
    {
        bool first = true;
        os << "[";
        for(unsigned int i = 0; i < v.size(); i++)
        {
            if(!first)
                os << ", ";
            os << v[i];
            first = false;
        }
        return os << "]";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii;
            first = false;
        }
        return os << "]";
    }

    template<typename T1, typename T2>
    inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii ;
            first = false;
        }
        return os << "]";
    }
#else
    #define debug(args...)
#endif
#define mod 1000000007
#define ok order_of_key
#define fo find_by_order
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repp(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define newl cout<<'\n'
#define inf 1000000000
#define repaa(i,a) for(auto i=a.begin();i!=a.end();++i)
#define pb push_back
#define test cout<<"test"<<endl
#define start int tt;cin>>tt;while(tt--)
#define tc int tt;tt=read();while(tt--)
#define nl "\n"
#define startk int tt;cin>>tt;for(int kk=1;kk<=tt;kk++)
#define mem(v,i) memset(v,i,sizeof(v))//Use mem(v,60) to initialize with 10^9
#define all(x) x.begin(), x.end()
#define inf1 1e18
#define repa(i,a) for (auto i : a)
#define X first
#define Y second
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define dec(v) sort(v.begin(),v.end(),greater<int>());
#define in(a,n) repp(jjj,n)cin>>a[jjj];
#define re(a,n) repp(jjj,n)a[jjj]=read();
#define retree(a,m) repp(i,m){int tmp1=read()-1,tmp2=read()-1;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define intree(a,m) repp(i,m){int tmp1,tmp2;cin>>tmp1>>tmp2;tmp1--,tmp2--;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define ins insert
#define er erase
#define sz(a) (int)(a.size())
#define big cpp_int
#define ll128 int128_t //Write (ll128) when using this type.
#define print(x,n,k) repp(i,n){repp(j,k)cout<<x[i][j]<<"  ";newl;}
#define mt make_tuple
#define eb emplace_back
#define p_q priority_queue
#define time cerr << 1.0 * clock()
#define bp(i) __builtin_popcountll(i)
#define precision(x) cout << fixed << setprecision(x);
typedef long double ld;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pair<int,int>> vip;
typedef vector<pair<int,ll>> vil; // use for Dijkstra wih long weights
typedef vector<pair<ll,ll>> vll;
typedef pair<int, int> ip;
typedef pair<int, ll> il;
typedef pair<ll, ll> pll;
typedef tuple<int,int,int> state;
typedef tuple<ll,int,int> statel;
#ifdef Fading
#define gc getchar
#endif
#ifndef Fading
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
#endif
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
template<typename T>
T Min(T v) {
  return v;
}
template<typename T, typename... Args>
T Min(T first, Args... args) {
  return min(first , Min(args...));
}
template<typename T>
T Max(T v) {
  return v;
}
template<typename T, typename... Args>
T Max(T first, Args... args) {
  return max(first , Max(args...));
}
template<typename T>
T mult(T v) {
  return v;
}
template<typename T, typename... Args>
T mult(T first, Args... args) {
  return mult((first * mult(args...))%mod);
}
template<typename T>
T addr(T v) {
  return v;
}
template<typename T, typename... Args>
T addr(T first, Args... args) {
  return addr((first + addr(args...))%mod);
}
template<class T> inline bool remax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline bool remin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class A, class B>
void add(A &a, B b)//adds in a. Does not return anything.
{
    a += b;
    if (a < 0LL) a += mod;
    if (a >= mod) a -= mod;
}
template<class A, class B>
void mul(A &a, B b)//adds in a. Does not return anything.
{
    a=(a*b)%mod;
}
inline int to_i(char c)
{
    return c - 'a';
}
/*
int n;
const int NNNN=1000*1000+5;
ll BITTree1[NNNN],BITTree2[NNNN];
ll getSum(ll BITree[],int index){
    ll sum = 0;
    index++;
    while (index>0){
        sum += BITree[index];
        index -= index & (-index);
    }
    return sum;
}
void updateBIT(ll BITree[],int index,ll val){
    index++;
    while (index <= n){
        BITree[index] += val;
        index += index & (-index);
    }
}
int sum(int x){
    return getSum(BITTree1,x)*x-getSum(BITTree2,x);
}
void updateRange(int l,int r,int val){
    updateBIT(BITTree1,l,val);
    updateBIT(BITTree1,r+1,-val);
    updateBIT(BITTree2,l,val*(l-1));
    updateBIT(BITTree2,r+1,-val*r);
}
ll rangeSum(int l, int r){
    return sum(r)-sum(l-1);
}
*/
/*
const int NN=2*1000*100+4;
int dsu[NN],sub[NN];
void pre(){
repp(i,NN)dsu[i]=i,sub[i]=1;
}
int root(int a){
    while(dsu[a]!=a){
        dsu[a]=dsu[dsu[a]];
        a=dsu[a];
    }
    return a;
}
void uni(int a,int b){
    int _a=root(a);
    int _b=root(b);
    if(_a==_b)return ;
    if(sub[_a]>sub[_b]){
        dsu[_b]=dsu[_a];
        sub[_a]+=sub[_b];
    }
    else {
        dsu[_a]=dsu[_b];
        sub[_b]+=sub[_a];
    }
}
*/
/*
const int LOGN=19,NNN=1000*1000+5;
int DP[LOGN][NN],level[NNN];
void dfs0(int u)
{
	for(auto it=a[u].begin();it!=a[u].end();it++)
		if(*it!=DP[0][u])
		{
			DP[0][*it]=u;
			level[*it]=level[u]+1;
			dfs0(*it);
		}
}
void preprocess()
{
	dfs0(0);
	for(int i=1;i<LOGN;i++)
		for(int j=0;j<n;j++)
			DP[i][j] = DP[i-1][DP[i-1][j]];
}
int lca(int a,int b)
{
	if(level[a]>level[b])swap(a,b);
	int d = level[b]-level[a];
	for(int i=0;i<LOGN;i++)
		if(d&(1<<i))
			b=DP[i][b];
	if(a==b)return a;
	for(int i=LOGN-1;i>=0;i--)
		if(DP[i][a]!=DP[i][b])
			a=DP[i][a],b=DP[i][b];
	return DP[0][a];
}
*/
/*
ll poww(ll a, ll b)
{
    ll val = 1;
    a %= mod;
    while (b > 0)
    {
        if (b % 2) val = mult(a, val);
        a = mult(a, a);
        b >>= 1;
    }
    return val % mod;
}
ll inv(ll a)
{
    return poww(a , mod - 2);
}
*/
/*
const int jj=2e5+5;
ll fac[jj];
void pre(){
    fac[0] = 1;
    for (int i=1 ; i<jj; i++)
    fac[i] = fac[i-1]*i%mod;
}
ll nc(int n,int r)
{
   if (r==0)
      return 1;
   return (fac[n]*inv(fac[r])%mod*inv(fac[n-r])%mod)%mod;
}
*/
/*
string to_str(ll a){
    string mystring;
    stringstream mystream;
    mystream << a;
    mystring = mystream.str();
    return mystring;
}
*/
/*
bool iscomp[100000];
vi primes;
void sieve(int n){
    for(int i=2;i<=n;++i){
        if(!iscomp[i]){
            primes.eb(i);
            for(int j=i*i;j<=n;j+=i)iscomp[j]=1;
        }
    }
}
*/
/*
vl prime(ll n){
    vl v;
    for(int i=2;i*i<=n;++i){
        if(n%i==0)v.eb(i);
        while(n%i==0)n/=i;
    }
    if(n!=1)v.eb(n);
    return v;
}
*/
/*
ll gcd1(ll a, ll b, ll &x, ll &y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcd1(b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
bool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g) {
    g = gcd1(abs1(a), abs1(b), x0, y0);
    if (c % g!=0) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}
*/
/*
int cc(ll x){
    int ans=0;
    while(x){if(x&1LL)ans++;x/=2;}
    return ans;
}
*/
// Treap
// auto cmp = [](ip a, ip b){return a.X==b.X?a.Y>b.Y:a.X>b.X;};
 //   set<ip,decltype(cmp)> s(cmp);

//-----------------------------------------------------end--------------------------------------//

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    tc{
        ll a=read(),b=read();
        ll diff = abs(a-b);
        a = max(a,b);
        b = a-diff;
        ll sum = 0;
        int add = 1;
        while(sum < diff){sum+=add++;debug(sum,add);}
        if(sum == diff)cout << add -1 ;
        else cout << add ;
        newl;
    }
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int maxn=2e5+10;
const ll inf=1e9;
ll mod=1e9+7;;

int main(void)
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        ll a,b;
        scanf("%lld%lld",&a,&b);
        if(a>b)
            swap(a,b);
        ll t=b-a;
        ll ans=0,i=1;
        while(t!=0)
        {
            if(t-i<0)
            {
                ans+=min(t*2,abs(t-i)*2+1);
                break;
            }
            else
                ans++;
            t-=i;
            i++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int maxn=2e5+10;
const ll inf=1e9;
ll mod=1e9+7;;

int main(void)
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        if(a>b)
            swap(a,b);
        int t=b-a;
        int ans=0;
        for(int i=1;i<=b-a;i++)
        {
            if(t-i<0)
            {
                ans+=t*2;
                break;
            }
            else
                ans++;
            t-=i;
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int maxn=2e5+10;
const ll inf=1e9;
ll mod=1e9+7;;

int main(void)
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        if(a>b)
            swap(a,b);
        int t=b-a;
        int ans=0,i=1;
        while(t!=0)
        {
            if(t-i<0)
            {
                ans+=t*2;
                break;
            }
            else
                ans++;
            t-=i;
            i++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int maxn=2e5+10;
const ll inf=1e9;
ll mod=1e9+7;;

int main(void)
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        ll a,b;
        scanf("%lld%lld",&a,&b);
        if(a>b)
            swap(a,b);
        ll t=b-a;
        ll ans=0,i=1;
        while(t!=0)
        {
            if(t-i<0)
            {
                ans+=t*2;
                break;
            }
            else
                ans++;
            t-=i;
            i++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int maxn=2e5+10;
const ll inf=1e9;
ll mod=1e9+7;;

int main(void)
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        ll a,b;
        scanf("%lld%lld",&a,&b);
        if(a>b)
            swap(a,b);
        ll t=b-a,sum=0,i;
        if(t==2)
        {
            printf("3\n");
            continue;
        }
        if(t==3)
        {
            printf("2\n");
            continue;
        }
        for(i=1;i<=t;i++)
        {
             if(sum>=t)
                break;
            sum+=i;
        }
        if(sum==t)
            printf("%lld\n",i-1);
        else
        {
            if(t%2==0)
            {
                if(i%2==0)
                    printf("%lld\n",i);
                else
                    printf("%lld\n",i+1);
            }
            else
            {
                if(i%2!=0)
                    printf("%lld\n",i);
                else
                    printf("%lld\n",i+1);
            }
        }
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#define lowbit(x) x&(-x)
//priority_queue <int,vector<int>,greater<int> > q;
using namespace std;

typedef long long ll;
const int maxn=1e6+10;
const ll inf=1e9+7;
ll mod=1e9+7;

ll sum[maxn];
int main(void)
{
    int t;
    scanf("%d",&t);
    sum[0]=0;
    for(int i=1;i<=1000000;i++)
        sum[i]=sum[i-1]+i;
        int ans;
    while(t--)
    {
        ll a,b;
        scanf("%lld%lld",&a,&b);
        ll t=abs(a-b);
        if(t==0)
        {
            printf("0\n");
            continue;
        }
        for(int i=1;i<=1000000;i++)
        {
            if(sum[i]>=t&&(sum[i]-t)%2==0)
            {
                ans=i;
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int maxn=2e5+10;
const ll inf=1e9;
ll mod=1e9+7;;

int main(void)
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        ll a,b;
        scanf("%lld%lld",&a,&b);
        if(a>b)
            swap(a,b);
        ll t=b-a,sum=0,i;
        if(t==2)
        {
            printf("3\n");
            continue;
        }
        if(t==3)
        {
            printf("2\n");
            continue;
        }
        for(i=1;i<=t;i++)
        {
             if(sum>=t)
                break;
            sum+=i;
        }
        if(sum==t)
            printf("%d\n",i-1);
        else
        {
            if(t%2==0)
            {
                if(i%2==0)
                    printf("%d\n",i);
                else
                    printf("%d\n",i+1);
            }
            else
            {
                if(i%2!=0)
                    printf("%d\n",i);
                else
                    printf("%d\n",i+1);
            }
        }
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int maxn=2e5+10;
const ll inf=1e9;
ll mod=1e9+7;;

int main(void)
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        ll a,b;
        scanf("%lld%lld",&a,&b);
        if(a>b)
            swap(a,b);
        ll t=b-a;
        ll ans=0,i=1;
        while(t!=0)
        {
            if(t-i<0)
            {
                ans+=min(t*2,abs(t-i)*2);
                break;
            }
            else
                ans++;
            t-=i;
            i++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int maxn=2e5+10;
const ll inf=1e9;
ll mod=1e9+7;;

int main(void)
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        ll a,b;
        scanf("%lld%lld",&a,&b);
        if(a>b)
            swap(a,b);
        ll t=b-a;
        ll ans=0,i=1;
        while(t!=0)
        {
            if(t-i<0)
            {
                ll t1=0,t2=0,tt=t,tt2=abs(t-i);
                while(tt!=0&&(int)sqrt(tt)!=1)
                {
                    ll k=(int)sqrt(tt);
                    t1+=k*2;
                    tt-=k*k;
                }
                t1+=tt*2;
                while(tt2!=0&&(int)sqrt(tt2)!=1)
                {
                    ll k=(int)sqrt(tt2);
                    t2+=k*2;
                    tt2-=k*k;
                }
                t2+=tt2*2;
                ans+=min(t1,t2);
                break;
            }
            else
                ans++;
            t-=i;
            i++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

int main()
{
  int t;
  cin>>t;
  while(t--)
  {
      ll a,b;
      cin>>a>>b;
      if(a>b)
      swap(a,b);
      ll c=0;
      ll ans=0;
      while(a!=b)
      {
          ll x=(sqrt((2*c+1)*(2*c+1)+8*(b-a))-(2*c+1))/2;
          //cout<<x;

          ans+=x;
          a+=(c)*x+(x*(x+1)/2);
          c+=x;
          ans+=abs(b-a)*2;
          break;
      }
      cout<<ans<<endl;
  }

}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

int main()
{
  int t;
  cin>>t;
  while(t--)
  {
      ll a,b;
      cin>>a>>b;
      if(a>b)
      swap(a,b);
      ll c=1;
      ll ans=0;
      while(a!=b)
      {
          ll x=sqrt(1+8*((b-a)/c))/2;
          //cout<<x;

          ans+=x;
          a+=c*(x*(x+1)/2);
          c+=x;
          if(a+c+2==b+c+1)
          {
              ans++;
              break;
          }
          if(a>b)
          swap(a,b);
      }
      cout<<ans<<endl;
  }

}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

int main()
{
  int t;
  cin>>t;
  while(t--)
  {
      ll a,b;
      cin>>a>>b;
      if(a>b)
      swap(a,b);
      ll c=1;
      ll ans=0;
      while(a!=b)
      {
          ll x=(sqrt(1+8*((b-a)/c))-1)/2;
          //cout<<x;

          ans+=x;
          a+=c*(x*(x+1)/2);
          c+=x;
          if(abs(a-b)==1)
          {
              ans+=2;
              break;
          }
          if(a>b)
          swap(a,b);
      }
      cout<<ans<<endl;
  }

}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

int main()
{
  int t;
  cin>>t;
  while(t--)
  {
      ll a,b;
      cin>>a>>b;
      if(a>b)
      swap(a,b);
      ll c=1;
      ll ans=0;
      while(a!=b)
      {
          ll x=(sqrt(1+8*((b-a)/c))-1)/2;
          //cout<<x;

          ans+=x;
          a+=(c-1)*x+(x*(x+1)/2);
          c+=x;
          if(abs(a-b)==1)
          {
              ans+=2;
              break;
          }
          if(a>b)
          swap(a,b);
      }
      cout<<ans<<endl;
  }

}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

int main()
{
  int t;
  cin>>t;
  while(t--)
  {
      ll a,b;
      cin>>a>>b;
      if(a>b)
      swap(a,b);
      ll c=0;
      ll ans=0;
      while(a!=b)
      {
          ll x=(sqrt((2*c+1)*(2*c+1)+8*(b-a))-(2*c+1))/2;
          //cout<<x;

          ans+=x;
          a+=(c)*x+(x*(x+1)/2);
          c+=x;
          ans+=min(abs(b-a),abs(b-a-x-1))*2;
          break;
      }
      cout<<ans<<endl;
  }

}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

int main()
{
    int q;
    cin>>q;
    while(q--)
    {
       ll a,b;
       cin>>a>>b;
       ll x=0,y=0;
       while(1)
       {
           ll p=y+a+b;
           if(p%2==0)
           {
               if(p/2>=max(a,b))
               {
                   cout<<x<<endl;
                   break;
               }

           }
           x++;
           y+=x;
       }
    }
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

int main()
{
  int t;
  cin>>t;
  while(t--)
  {
      ll a,b;
      cin>>a>>b;
      if(a>b)
      swap(a,b);
      ll c=0;
      ll ans=0;
      while(a!=b)
      {
          ll x=(sqrt((2*c+1)*(2*c+1)+8*(b-a))-(2*c+1))/2;
          //cout<<x;

          ans+=x;
          a+=(c)*x+(x*(x+1)/2);
          c+=x;
          ans+=min(abs(b-a)*2,abs(b-a-x-1)*2+1);
          break;
      }
      cout<<ans<<endl;
  }

}


#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

int main()
{
  int t;
  cin>>t;
  while(t--)
  {
      ll a,b;
      cin>>a>>b;
      if(a>b)
      swap(a,b);
      ll c=0;
      ll ans=0;
      while(a!=b)
      {
          ll x=(sqrt((2*c+1)*(2*c+1)+8*(b-a))-(2*c+1))/2;
          //cout<<x;

          ans+=x;
          a+=(c)*x+(x*(x+1)/2);
          c+=x;
          if(abs(a-b)==1)
          {
              ans+=2;
              break;
          }
          if(a!=b)
          {
              b+=c+1;
              c++;
              ans++;
          }
          if(a>b)
          swap(a,b);
      }
      cout<<ans<<endl;
  }

}


// Hail god Yato

#include <bits/stdc++.h>
using namespace std;

#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                ll oper(ll k){
                        ll l=0,r=MAX,c=0;
                        while(l<r){
                                ll mid=(l+r)>>1;
                                if(mid*(mid+1)/2>=k)
                                        r=mid;
                                else
                                        l=mid+1;
                        }
                        return l;
                }
                void solve(){
                        ll fst,snd;
                        cin>>fst>>snd;
                        if(fst>snd)
                                swap(fst,snd);
                        if(fst==snd){
                                cout<<"0\n";
                                return ;
                        }
                        for(ll n=1;;n++){
                                ll sm=n*(n+1)/2;
                                if(sm<snd-fst)
                                        continue;
                                // cout<<n;
                                rep(i,0,n+1)
                                        if(fst+sm-i==snd+i){
                                                cout<<n<<'\n';
                                                return ;
                                        }
                                // cout<<n+1<<'\n';
                                // return ;
                        }
                }
                int main(){
                        hs;
                        ll t;
                        t=1;
                        cin>>t;
                        for (int i=1; i<=t; i++){
                                //printf("Case #%d: ", i);
                                solve();
                         }
        return 0;
}


// Hail god Yato

#include <bits/stdc++.h>
using namespace std;

#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                ll oper(ll k){
                        ll l=0,r=MAX,c=0;
                        while(++c<100){
                                ll mid=(l+r+1)>>1;
                                if(mid*(mid+1)/2>=k)
                                        r=mid;
                                else
                                        l=mid+1;
                        }
                        return l;
                }
                void solve(){
                        ll fst,snd;
                        cin>>fst>>snd;
                        if(fst>snd)
                                swap(fst,snd);
                        if(fst==snd){
                                cout<<"0\n";
                                return ;
                        }
                        ll n=oper(snd-fst);
                        if(n*(n+1)/2==snd-fst)
                                cout<<n<<'\n';
                        else
                                cout<<n+1<<'\n';
                }
                int main(){
                        hs;
                        ll t;
                        t=1;
                        cin>>t;
                        for (int i=1; i<=t; i++){
                                //printf("Case #%d: ", i);
                                solve();
                         }
        return 0;
}


// Hail god Yato

#include <bits/stdc++.h>
using namespace std;

#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                ll oper(ll k){
                        ll l=0,r=MAX,c=0;
                        while(l<r){
                                ll mid=(l+r)>>1;
                                if(mid*(mid+1)/2>=k)
                                        r=mid;
                                else
                                        l=mid+1;
                        }
                        return l;
                }
                void solve(){
                        ll fst,snd;
                        cin>>fst>>snd;
                        if(fst>snd)
                                swap(fst,snd);
                        if(fst==snd){
                                cout<<"0\n";
                                return ;
                        }
                        for(ll n=1;;n++){
                                ll sm=n*(n+1)/2;
                                if(sm<snd-fst)
                                        continue;
                                // cout<<n;
                                rep(i,0,n+1)
                                        if(fst+sm-i==snd+i){
                                                cout<<n<<'\n';
                                                return ;
                                        }
                                cout<<n+1<<'\n';
                                return ;
                        }
                }
                int main(){
                        hs;
                        ll t;
                        t=1;
                        cin>>t;
                        for (int i=1; i<=t; i++){
                                //printf("Case #%d: ", i);
                                solve();
                         }
        return 0;
}


// Hail god Yato

#include <bits/stdc++.h>
using namespace std;

#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                ll oper(ll k){
                        ll l=0,r=MAX,c=0;
                        while(++c<100){
                                ll mid=(l+r+1)>>1;
                                if(mid*(mid+1)/2>=k)
                                        r=mid;
                                else
                                        l=mid+1;
                        }
                        return l;
                }
                void solve(){
                        ll fst,snd;
                        cin>>fst>>snd;
                        if(fst>snd)
                                swap(fst,snd);
                        if(fst==snd){
                                cout<<"0\n";
                                return ;
                        }
                        ll n=oper(snd-fst);
                        if(n*(n+1)/2==snd-fst)
                                cout<<n<<'\n';
                        else{
                                ll sm=n*(n+1)/2;
                                // cout<<n;
                                rep(i,1,n)
                                        if(fst+sm-i==snd+i){
                                                cout<<n<<'\n';
                                                return ;
                                        }
                                cout<<n+1<<'\n';
                        }
                }
                int main(){
                        hs;
                        ll t;
                        t=1;
                        cin>>t;
                        for (int i=1; i<=t; i++){
                                //printf("Case #%d: ", i);
                                solve();
                         }
        return 0;
}


// Hail god Yato

#include <bits/stdc++.h>
using namespace std;

#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                ll oper(ll k){
                        ll l=1,r=MAX,c=0;
                        while(++c<100){
                                ll mid=(l+r)>>1;
                                if(mid*(mid+1)/2>=k)
                                        r=mid;
                                else
                                        l=mid+1;
                        }
                        return l;
                }
                void solve(){
                        ll fst,snd;
                        cin>>fst>>snd;
                        if(fst>snd)
                                swap(fst,snd);
                        if(fst==snd){
                                cout<<"0\n";
                                return ;
                        }
                        ll n=oper(snd-fst);
                        if(n*(n+1)/2==snd-fst)
                                cout<<n;
                        else
                                cout<<n+1;
                        cout<<'\n';
                        // cout<<oper(11);
                }
                int main(){
                        hs;
                        ll t;
                        t=1;
                        cin>>t;
                        for (int i=1; i<=t; i++){
                                //printf("Case #%d: ", i);
                                solve();
                         }
        return 0;
}


// Hail god Yato

#include <bits/stdc++.h>
using namespace std;

#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                ll oper(ll k){
                        ll l=0,r=MAX,c=0;
                        while(l<r){
                                ll mid=(l+r)>>1;
                                if(mid*(mid+1)/2>=k)
                                        r=mid;
                                else
                                        l=mid+1;
                        }
                        return l;
                }
                void solve(){
                        ll fst,snd;
                        cin>>fst>>snd;
                        if(fst>snd)
                                swap(fst,snd);
                        if(fst==snd){
                                cout<<"0\n";
                                return ;
                        }
                        ll n=oper(snd-fst);

                                ll sm=n*(n+1)/2;
                                if(sm%2 != (snd-fst)%2)
                                        ++n;
                                cout<<n<<'\n';
                        // }
                }
                int main(){
                        hs;
                        ll t;
                        t=1;
                        cin>>t;
                        for (int i=1; i<=t; i++){
                                //printf("Case #%d: ", i);
                                solve();
                         }
        return 0;
}


// Hail god Yato

#include <bits/stdc++.h>
using namespace std;

#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                ll oper(ll k){
                        ll l=0,r=MAX,c=0;
                        while(l<r){
                                ll mid=(l+r)>>1;
                                if(mid*(mid+1)/2>=k)
                                        r=mid;
                                else
                                        l=mid+1;
                        }
                        return l;
                }
                void solve(){
                        ll fst,snd;
                        cin>>fst>>snd;
                        if(fst>snd)
                                swap(fst,snd);
                        if(fst==snd){
                                cout<<"0\n";
                                return ;
                        }
                        ll n=oper(snd-fst);
                        if(n*(n+1)/2==snd-fst)
                                cout<<n<<'\n';
                        else{
                                ll sm=n*(n+1)/2;
                                // cout<<n;
                                rep(i,1,n)
                                        if(fst+sm-i==snd+i){
                                                cout<<n<<'\n';
                                                return ;
                                        }
                                cout<<n+1<<'\n';
                        }
                }
                int main(){
                        hs;
                        ll t;
                        t=1;
                        cin>>t;
                        for (int i=1; i<=t; i++){
                                //printf("Case #%d: ", i);
                                solve();
                         }
        return 0;
}


// Hail god Yato

#include <bits/stdc++.h>
using namespace std;

#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                ll oper(ll k){
                        ll l=0,r=MAX,c=0;
                        while(l<r){
                                ll mid=(l+r)>>1;
                                if(mid*(mid+1)/2>=k)
                                        r=mid;
                                else
                                        l=mid+1;
                        }
                        return l;
                }
                void solve(){
                        ll fst,snd;
                        cin>>fst>>snd;
                        if(fst>snd)
                                swap(fst,snd);
                        if(fst==snd){
                                cout<<"0\n";
                                return ;
                        }
                        for(ll n=1;;n++){
                                ll sm=n*(n+1)/2;
                                if(sm<snd-fst)
                                        continue;
                                // cout<<n;
                                // rep(i,0,n+1)
                                        if(sm%2 == (snd-fst)%2){
                                                cout<<n<<'\n';
                                                return ;
                                        }
                                // cout<<n+1<<'\n';
                                // return ;
                        }
                }
                int main(){
                        hs;
                        ll t;
                        t=1;
                        cin>>t;
                        for (int i=1; i<=t; i++){
                                //printf("Case #%d: ", i);
                                solve();
                         }
        return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define write(x) cerr << #x << " = " << (x) << ", ";
#define writeI0 cerr << "i = " << 0 << ", ";
#define dumpI0 cerr << "i = " << 0 << endl;
#define printSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printPairSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << '(' << it->first << ", " << it->second << ')' : cout << " (" << it->first << ", " << it->second << ')'; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printArray(a,x,y) for(auto it = a+x; it != a+y; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;
#define PrintArray(a,x,y) for(auto it = a+x; it != a+y+1; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

ll s[44722];

// Last Occurence (Array)
int binarySearch(int key) {
	int lo = 0, hi = 44721;
	while(lo <= hi) {
		int mid = (hi + lo) / 2;
		if(s[mid] <= key)
			lo = mid + 1;
	    else
	        hi = mid - 1;
	}
	return lo - 1;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    s[0] = 0;
    Rep(i, 1, 44721) {
        s[i] = s[i-1] + i;
    }
    int tc; int a, b;
    cin >> tc;
    while(tc--) {
        cin >> a >> b;
        if (a > b)
            swap (a, b);
        b -= a;
        int n = binarySearch(b);
        b -= s[n];
        if (!b) {
            cout << n << '\n';
        }
        else {
            int c = (n+1) - b;
            if (c % 2 == 0 && c >= 2) {
                cout << n+1 << '\n';
                continue;
            }
            int d = 2*n + 3 - b;
            if (d % 2 == 0 && d >= 2 && d <= 2*n) {
                cout << n+2 << '\n';
                continue;
            }
            else {
                cout << n + b*2 << '\n';
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define write(x) cerr << #x << " = " << (x) << ", ";
#define writeI0 cerr << "i = " << 0 << ", ";
#define dumpI0 cerr << "i = " << 0 << endl;
#define printSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printPairSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << '(' << it->first << ", " << it->second << ')' : cout << " (" << it->first << ", " << it->second << ')'; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printArray(a,x,y) for(auto it = a+x; it != a+y; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;
#define PrintArray(a,x,y) for(auto it = a+x; it != a+y+1; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

ll s[44722];

// Last Occurence (Array)
int binarySearch(int key) {
	int lo = 0, hi = 44721;
	while(lo <= hi) {
		int mid = (hi + lo) / 2;
		if(s[mid] <= key)
			lo = mid + 1;
	    else
	        hi = mid - 1;
	}
	return lo - 1;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    s[0] = 0;
    Rep(i, 1, 44721) {
        s[i] = s[i-1] + i;
    }
    int tc; int a, b;
    cin >> tc;
    while(tc--) {
        cin >> a >> b;
        if (a > b)
            swap (a, b);
        b -= a;
        int n = binarySearch(b);
        int x = n % 2 ^ 1;
        int m = n;
        b -= s[n];
        while (b) {
            int c = (n+1) - b;
            if (c >= 2 && (c <= 2 * m || c <= 2 * n && c % 2 == 0 && c/2 % 2 == x) {
                n++;
                break;
            }
            else {
                b--;
                n += 2;
            }
        }

        cout << n << '\n';
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define write(x) cerr << #x << " = " << (x) << ", ";
#define writeI0 cerr << "i = " << 0 << ", ";
#define dumpI0 cerr << "i = " << 0 << endl;
#define printSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printPairSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << '(' << it->first << ", " << it->second << ')' : cout << " (" << it->first << ", " << it->second << ')'; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printArray(a,x,y) for(auto it = a+x; it != a+y; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;
#define PrintArray(a,x,y) for(auto it = a+x; it != a+y+1; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

ll s[44722];

// Last Occurence (Array)
int binarySearch(int key) {
	int lo = 0, hi = 44721;
	while(lo <= hi) {
		int mid = (hi + lo) / 2;
		if(s[mid] <= key)
			lo = mid + 1;
	    else
	        hi = mid - 1;
	}
	return lo - 1;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    s[0] = 0;
    Rep(i, 1, 44721) {
        s[i] = s[i-1] + i;
    }
    int tc; int a, b;
    cin >> tc;
    while(tc--) {
        cin >> a >> b;
        if (a > b)
            swap (a, b);
        b -= a;
        int n = binarySearch(b);
        int m = n;
        b -= s[n];
        while (b) {
            int c = (n+1) - b;
            if (c % 2 == 0 && c >= 2 && c <= 2 * m) {
                if (n > m) cout << '0';
                n++;
                break;
            }
            else {
                int d = (n+1) + (n+2) - b;
                if (d % 2 == 0 && d >= 2 && d <= 2 * m) {
                    if (n > m) cout << '0';
                    n+=2;
                    break;
                }
                b--;
                n += 2;
            }
        }

        cout << n << '\n';
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define write(x) cerr << #x << " = " << (x) << ", ";
#define writeI0 cerr << "i = " << 0 << ", ";
#define dumpI0 cerr << "i = " << 0 << endl;
#define printSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printPairSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << '(' << it->first << ", " << it->second << ')' : cout << " (" << it->first << ", " << it->second << ')'; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printArray(a,x,y) for(auto it = a+x; it != a+y; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;
#define PrintArray(a,x,y) for(auto it = a+x; it != a+y+1; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

ll s[44722];

// Last Occurence (Array)
int binarySearch(int key) {
	int lo = 0, hi = 44721;
	while(lo <= hi) {
		int mid = (hi + lo) / 2;
		if(s[mid] <= key)
			lo = mid + 1;
	    else
	        hi = mid - 1;
	}
	return lo - 1;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    s[0] = 0;
    Rep(i, 1, 44721) {
        s[i] = s[i-1] + i;
    }
    int tc; int a, b;
    cin >> tc;
    while(tc--) {
        cin >> a >> b;
        if (a > b)
            swap (a, b);
        b -= a;
        int n = binarySearch(b);
        int m = n;
        b -= s[n];
        while (b) {
            int c = (n+1) - b;
            if (c % 2 == 0 && c >= 2 && c <= 2 * m) {
                if (n > m) cout << '0';
                n++;
                break;
            }
            else {
                int d = (n+1) + (n+2) - b;
                if (d % 2 == 0 && d >= 2 && d <= 2 * m) {
                    n+=2;
                    break;
                }
                b--;
                n += 2;
            }
        }

        cout << n << '\n';
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define write(x) cerr << #x << " = " << (x) << ", ";
#define writeI0 cerr << "i = " << 0 << ", ";
#define dumpI0 cerr << "i = " << 0 << endl;
#define printSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printPairSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << '(' << it->first << ", " << it->second << ')' : cout << " (" << it->first << ", " << it->second << ')'; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printArray(a,x,y) for(auto it = a+x; it != a+y; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;
#define PrintArray(a,x,y) for(auto it = a+x; it != a+y+1; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

ll s[44722];

// Last Occurence (Array)
int binarySearch(int key) {
	int lo = 0, hi = 44721;
	while(lo <= hi) {
		int mid = (hi + lo) / 2;
		if(s[mid] <= key)
			lo = mid + 1;
	    else
	        hi = mid - 1;
	}
	return lo - 1;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    s[0] = 0;
    Rep(i, 1, 44721) {
        s[i] = s[i-1] + i;
    }
    int tc; int a, b;
    cin >> tc;
    while(tc--) {
        cin >> a >> b;
        if (a > b)
            swap (a, b);
        b -= a;
        int n = binarySearch(b);
        int x = n % 2 ^ 1;
        int m = n;
        b -= s[n];
        int z = 0;
        while (b) {
            int c = (n+1) - b;
            if (c % 2 == 0 && c >= 2 && (c <= 2 * m || c <= 2 * n && c/2 % 2 == x)) {
                n++;
                break;
            }
            else {
                int d = (n+1) + (n+2) - b;
                if (d % 2 == 0 && d >= 2 && (d <= 2 * m || d <= 2 * n && d/2 % 2 == x)) {
                    n+=2;
                    break;
                }
                b--;
                n += 2;
                z++;
                if (z == 2) {
                    cout << '0';
                    break;
                }
            }
        }

        cout << n << '\n';
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define write(x) cerr << #x << " = " << (x) << ", ";
#define writeI0 cerr << "i = " << 0 << ", ";
#define dumpI0 cerr << "i = " << 0 << endl;
#define printSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printPairSet(s) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << '(' << it->first << ", " << it->second << ')' : cout << " (" << it->first << ", " << it->second << ')'; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printArray(a,x,y) for(auto it = a+x; it != a+y; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;
#define PrintArray(a,x,y) for(auto it = a+x; it != a+y+1; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

ll s[44722];

// Last Occurence (Array)
int binarySearch(int key) {
	int lo = 0, hi = 44721;
	while(lo <= hi) {
		int mid = (hi + lo) / 2;
		if(s[mid] <= key)
			lo = mid + 1;
	    else
	        hi = mid - 1;
	}
	return lo - 1;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    s[0] = 0;
    Rep(i, 1, 44721) {
        s[i] = s[i-1] + i;
    }
    int tc; int a, b;
    cin >> tc;
    while(tc--) {
        cin >> a >> b;
        if (a > b)
            swap (a, b);
        b -= a;
        int n = binarySearch(b);
        int x = n % 2 ^ 1;
        int m = n;
        b -= s[n];
        int z = 0;
        while (b) {
            int c = (n+1) - b;
            if (c % 2 == 0 && c >= 2 && (c <= 2 * m || c <= 2 * n && c/2 % 2 == x)) {
                n++;
                break;
            }
            else {
                int d = (n+1) + (n+2) - b;
                if (d % 2 == 0 && d >= 2 && (d <= 2 * m || d <= 2 * n && d/2 % 2 == x)) {
                    n+=2;
                    break;
                }
                b--;
                n += 2;
                z++;
                if (z == 4) {
                    cout << '0';
                    break;
                }
            }
        }

        cout << n << '\n';
    }
    return 0;
}