#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);
        b -= s[n];
        if (!b)
            cout << n << '\n';
        else if (b*2 <= n)
            cout << n+1 << '\n';
        else
            cout << n+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];
        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 == 3) {
                    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 == 5) {
                    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[100001];

//Last Occurence (Array)
int binarySearch2(ll key) {
	int lo = 0, hi = 100000;
	while(lo <= hi) {
		int mid = lo + (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, 100000) {
        s[i] = s[i-1] + i;
    }
    int tc, a, b;
    cin >> tc;
    while(tc--) {
        cin >> a >> b;
        if (a > b)
            swap (a, b);
        int c = b-a;
        b = c;
        a = 0;
        int d = binarySearch2(b);
        if (d > 0)
            b -= s[d];
        if (b == 0) {
            cout << d << '\n';
            continue;
        }
        else {
            cout << (ll) d + (ll) 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;
}

// Last Occurence (Array)
int binarySearch2(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;
	}

	if (lo > 0 && s[lo-1] == key)
        return lo -1;
	return -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 if ((n+1-b) % 2 == 0 && (n+1-b) / 2 <= n+1 && (n+1-b) / 2 >= 1) {
            cout << n+1 << '\n';
        }
        else if ((2*n+3-b) % 2 == 0 && (2*n+3-b) / 2 <= n+2 && (2*n+3-b) / 2 >= 1) {
            cout << n+2 << '\n';
        }
        else if ((3*n+6-b) % 2 == 0 && (3*n+6-b) / 2 <= n+3 && (3*n+6-b) / 2 >= 1) {
            cout << n+3 << '\n';
        }
        else if ((2*n+3-b) % 2 == 0 && (2*n+3-b) / 2 <= 2*n+3 && (2*n+3-b) / 2 >= 3) {
            cout << n+2 << '\n';
        }
        else if ((3*n+6-b) % 2 == 0 && (3*n+6-b) / 2 <= 2*n+5 && (3*n+6-b) / 2 >= 3) {
            cout << n+3 << '\n';
        }
        else if ((3*n+6-b) % 2 == 0 && (3*n+6-b) / 2 <= 3*n+6 && (3*n+6-b) / 2 >= 6) {
            cout << n+3 << '\n';
        }
        else {
            cout << n+4 << '\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;
}

// Last Occurence (Array)
int binarySearch2(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;
	}

	if (lo > 0 && s[lo-1] == key)
        return lo -1;
	return -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];
        dump(b)
        dump(n)
        if (!b)
            cout << n << '\n';
        else if ((n+1-b) % 2 == 0 && (n+1-b) / 2 <= n+1 && (n+1-b) / 2 >= 1) {
            cout << n+1 << '\n';
        }
        else if ((2*n+3-b) % 2 == 0 && (2*n+3-b) / 2 <= n+2 && (2*n+3-b) / 2 >= 1) {
            cout << n+2 << '\n';
        }
        else if ((3*n+6-b) % 2 == 0 && (3*n+6-b) / 2 <= n+3 && (3*n+6-b) / 2 >= 1) {
            cout << n+3 << '\n';
        }
        else if ((n+1-b) % 2 == 0 && (n+1-b) / 2 <= 2*n+1 && (n+1-b) / 2 >= 3) {
            cout << n+1 << '\n';
        }
        else if ((2*n+3-b) % 2 == 0 && (2*n+3-b) / 2 <= 2*n+3 && (2*n+3-b) / 2 >= 3) {
            cout << n+2 << '\n';
        }
        else if ((3*n+6-b) % 2 == 0 && (3*n+6-b) / 2 <= 2*n+5 && (3*n+6-b) / 2 >= 3) {
            cout << n+3 << '\n';
        }
        else if ((n+1-b) % 2 == 0 && (n+1-b) / 2 <= 3*n+1 && (n+1-b) / 2 >= 6) {
            cout << n+1 << '\n';
        }
        else if ((2*n+3-b) % 2 == 0 && (2*n+3-b) / 2 <= 3*n+3 && (2*n+3-b) / 2 >= 6) {
            cout << n+2 << '\n';
        }
        else if ((3*n+6-b) % 2 == 0 && (3*n+6-b) / 2 <= 3*n+6 && (3*n+6-b) / 2 >= 6) {
            cout << n+3 << '\n';
        }
        else {
            cout << n+4 << '\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;
}

// Last Occurence (Array)
int binarySearch2(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;
	}

	if (lo > 0 && s[lo-1] == key)
        return lo -1;
	return -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 if ((n+1-b) % 2 == 0 && (n+1-b) / 2 >= 1) {
            cout << n+1 << '\n';
        }
        else if ((2*n+3-b) % 2 == 0 && (2*n+3-b) / 2 <= 2*n+1 && (2*n+3-b) / 2 >= 3) {
            cout << n+2 << '\n';
        }
        else if ((3*n+6-b) % 2 == 0 && (3*n+6-b) / 2 <= 3*n+3 && (3*n+6-b) / 2 >= 6) {
            cout << n+3 << '\n';
        }
        else {
            cout << n+4 << '\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 == 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;
            }
        }

        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];
        while (b) {
            int c = (n+1) - b;
            if (c % 2 == 0 && 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 int ll;
typedef long long int lli;
ll mod=1e9+7;
#include<string.h>
ll mod1=998244353;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> os;
#define mp make_pair
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>0;i--)
ll fact[100001];
bool prime[100001];
ll ll_max(ll a,ll b,ll c){
	return max(a,max(b,c));
}
int int_max(int a,int b,int c){
	return max(a,max(b,c));
}
ll ll_min(ll a,ll b,ll c){
	return min(a,min(b,c));
}
int int_min(int a,int b,int c){
	return min(a,min(b,c));
}
ll gcd(ll a,ll b,ll c){
	return __gcd(a,__gcd(b,c));
}
void sieve(int n)
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
double dist(ll i1,ll j1,ll k1,ll i2,ll j2,ll k2){
	double a=pow((i1-i2),2)+pow((j1-j2),2)+pow((k1-k2),2);
	a=sqrt(a);
	return a;
}
bool compare(pair<ll,ll> a,pair<ll,ll> b){
	if(a.first<b.first)
		return true;
	else if(a.first==b.first){
		if(a.second>b.second)
			return true;
		else
			return false;
	}
	else
		return false;
}
void buildTree(int arr[],int tree[], int start,int end,int node){
	if(start==end){
		tree[node]=arr[start];
		return;
	}
	int mid=(start+end)/2;
	buildTree(arr,tree,start,mid,2*node);
	buildTree(arr,tree,mid+1,end,2*node+1);
	tree[node]=tree[2*node]+tree[2*node+1];
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
	if(a.se==b.se)
		return a.fi<b.fi;
    return (a.second < b.second);
}
ll pow(ll a,ll b){
	if(a==1)
		return 1;
	if(b==0)
		return 1;
	ll c=pow(a,b/2);
	ll res=1;
	if(b%2){
		res=(c*c)%mod;
		res*=a;
		res%=mod;
	}
	else
		res=(c*c)%mod;
	return res;
}
int lower_bound1(vector<int> v,int n,int p){
	int l=0;
	int r=n;
	if(v[0]>=p)
		return 0;
	while(l<r){
		int mid=(l+r)/2;
		if(v[mid]<p)
			l=mid+1;
		else if(v[mid]==p){
			if(mid==0)
				r=mid;
			if(v[mid-1]==p)
				r=mid-1;
			else
				r=mid;
		}
		else if(v[mid]>p)
			r=mid;
	}
	return l;
}
void bfs(vector<int> v[],int n,int a1,int b,bool visited[],int &count){
	queue<int> q;
	q.push(a1);
	q.push(b);
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){

		}
	}
}
ll modInv(ll a){
	return pow(a,mod-2)%mod;
}
ll ncr(ll n,ll r){
	ll b=modInv(fact[n-r]);
	ll c=modInv(fact[r]);
	ll a=fact[n]*b;
	a%=mod;
	a*=c;
	a%=mod;
	return a;
}
void dfs(int i,bool visited[],vector<int> v[]){
	for(int j=0;j<v[i].size();j++){
		if(visited[v[i][j]]==false){
			visited[v[i][j]]=true;
			dfs(v[i][j],visited,v);
		}
	}
}
void factorial(ll n){
	fact[0]=1;
    for(ll i=1;i<=n;i++){
    	fact[i]=fact[i-1]*i;
    	fact[i]%=mod;
	}
}
void solve(){
	int n,a,b;
	cin>>a>>b;
	n=abs(a-b);
	if(n==0){
		cout<<0<<endl;
		return;
	}
	for(int i=1;i<10000;i++){
		if((i*(i+1))/2==n){
			cout<<i<<endl;
			return;
		}
		else if((i*(i+1))/2>n+1){
			cout<<i<<endl;
			return;
		}
		else if((i*(i+1))/2==n+1){
			cout<<i+1<<endl;
			return;
		}
	}
}
int main(){
    ll t=1;
    cin>>t;
    while(t--){
    	solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long int lli;
ll mod=1e9+7;
#include<string.h>
ll mod1=998244353;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> os;
#define mp make_pair
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>0;i--)
ll fact[100001];
bool prime[100001];
ll ll_max(ll a,ll b,ll c){
	return max(a,max(b,c));
}
int int_max(int a,int b,int c){
	return max(a,max(b,c));
}
ll ll_min(ll a,ll b,ll c){
	return min(a,min(b,c));
}
int int_min(int a,int b,int c){
	return min(a,min(b,c));
}
ll gcd(ll a,ll b,ll c){
	return __gcd(a,__gcd(b,c));
}
void sieve(int n)
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
double dist(ll i1,ll j1,ll k1,ll i2,ll j2,ll k2){
	double a=pow((i1-i2),2)+pow((j1-j2),2)+pow((k1-k2),2);
	a=sqrt(a);
	return a;
}
bool compare(pair<ll,ll> a,pair<ll,ll> b){
	if(a.first<b.first)
		return true;
	else if(a.first==b.first){
		if(a.second>b.second)
			return true;
		else
			return false;
	}
	else
		return false;
}
void buildTree(int arr[],int tree[], int start,int end,int node){
	if(start==end){
		tree[node]=arr[start];
		return;
	}
	int mid=(start+end)/2;
	buildTree(arr,tree,start,mid,2*node);
	buildTree(arr,tree,mid+1,end,2*node+1);
	tree[node]=tree[2*node]+tree[2*node+1];
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
	if(a.se==b.se)
		return a.fi<b.fi;
    return (a.second < b.second);
}
ll pow(ll a,ll b){
	if(a==1)
		return 1;
	if(b==0)
		return 1;
	ll c=pow(a,b/2);
	ll res=1;
	if(b%2){
		res=(c*c)%mod;
		res*=a;
		res%=mod;
	}
	else
		res=(c*c)%mod;
	return res;
}
int lower_bound1(vector<int> v,int n,int p){
	int l=0;
	int r=n;
	if(v[0]>=p)
		return 0;
	while(l<r){
		int mid=(l+r)/2;
		if(v[mid]<p)
			l=mid+1;
		else if(v[mid]==p){
			if(mid==0)
				r=mid;
			if(v[mid-1]==p)
				r=mid-1;
			else
				r=mid;
		}
		else if(v[mid]>p)
			r=mid;
	}
	return l;
}
void bfs(vector<int> v[],int n,int a1,int b,bool visited[],int &count){
	queue<int> q;
	q.push(a1);
	q.push(b);
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){

		}
	}
}
ll modInv(ll a){
	return pow(a,mod-2)%mod;
}
ll ncr(ll n,ll r){
	ll b=modInv(fact[n-r]);
	ll c=modInv(fact[r]);
	ll a=fact[n]*b;
	a%=mod;
	a*=c;
	a%=mod;
	return a;
}
void dfs(int i,bool visited[],vector<int> v[]){
	for(int j=0;j<v[i].size();j++){
		if(visited[v[i][j]]==false){
			visited[v[i][j]]=true;
			dfs(v[i][j],visited,v);
		}
	}
}
void factorial(ll n){
	fact[0]=1;
    for(ll i=1;i<=n;i++){
    	fact[i]=fact[i-1]*i;
    	fact[i]%=mod;
	}
}
void solve(){
	ll n,a,b;
	cin>>a>>b;
	n=abs(a-b);
	if(n==0){
		cout<<0<<endl;
		return;
	}
	for(int i=1;i<100000;i++){
		if((i*(i+1))/2==n){
			cout<<i<<endl;
			return;
		}
		else if((((i*(i+1))/2)-n)%2==0&&(i*(i+1))/2>n){
			cout<<i<<endl;
			return;
		}
	}

}
int main(){
    ll t=1;
    cin>>t;
    while(t--){
    	solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long int lli;
ll mod=1e9+7;
#include<string.h>
ll mod1=998244353;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> os;
#define mp make_pair
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>0;i--)
ll fact[100001];
bool prime[100001];
ll ll_max(ll a,ll b,ll c){
	return max(a,max(b,c));
}
int int_max(int a,int b,int c){
	return max(a,max(b,c));
}
ll ll_min(ll a,ll b,ll c){
	return min(a,min(b,c));
}
int int_min(int a,int b,int c){
	return min(a,min(b,c));
}
ll gcd(ll a,ll b,ll c){
	return __gcd(a,__gcd(b,c));
}
void sieve(int n)
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
double dist(ll i1,ll j1,ll k1,ll i2,ll j2,ll k2){
	double a=pow((i1-i2),2)+pow((j1-j2),2)+pow((k1-k2),2);
	a=sqrt(a);
	return a;
}
bool compare(pair<ll,ll> a,pair<ll,ll> b){
	if(a.first<b.first)
		return true;
	else if(a.first==b.first){
		if(a.second>b.second)
			return true;
		else
			return false;
	}
	else
		return false;
}
void buildTree(int arr[],int tree[], int start,int end,int node){
	if(start==end){
		tree[node]=arr[start];
		return;
	}
	int mid=(start+end)/2;
	buildTree(arr,tree,start,mid,2*node);
	buildTree(arr,tree,mid+1,end,2*node+1);
	tree[node]=tree[2*node]+tree[2*node+1];
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
	if(a.se==b.se)
		return a.fi<b.fi;
    return (a.second < b.second);
}
ll pow(ll a,ll b){
	if(a==1)
		return 1;
	if(b==0)
		return 1;
	ll c=pow(a,b/2);
	ll res=1;
	if(b%2){
		res=(c*c)%mod;
		res*=a;
		res%=mod;
	}
	else
		res=(c*c)%mod;
	return res;
}
int lower_bound1(vector<int> v,int n,int p){
	int l=0;
	int r=n;
	if(v[0]>=p)
		return 0;
	while(l<r){
		int mid=(l+r)/2;
		if(v[mid]<p)
			l=mid+1;
		else if(v[mid]==p){
			if(mid==0)
				r=mid;
			if(v[mid-1]==p)
				r=mid-1;
			else
				r=mid;
		}
		else if(v[mid]>p)
			r=mid;
	}
	return l;
}
void bfs(vector<int> v[],int n,int a1,int b,bool visited[],int &count){
	queue<int> q;
	q.push(a1);
	q.push(b);
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){

		}
	}
}
ll modInv(ll a){
	return pow(a,mod-2)%mod;
}
ll ncr(ll n,ll r){
	ll b=modInv(fact[n-r]);
	ll c=modInv(fact[r]);
	ll a=fact[n]*b;
	a%=mod;
	a*=c;
	a%=mod;
	return a;
}
void dfs(int i,bool visited[],vector<int> v[]){
	for(int j=0;j<v[i].size();j++){
		if(visited[v[i][j]]==false){
			visited[v[i][j]]=true;
			dfs(v[i][j],visited,v);
		}
	}
}
void factorial(ll n){
	fact[0]=1;
    for(ll i=1;i<=n;i++){
    	fact[i]=fact[i-1]*i;
    	fact[i]%=mod;
	}
}
void solve(){
	int n,a,b;
	cin>>a>>b;
	n=abs(a-b);
	if(n==0){
		cout<<0<<endl;
		return;
	}
	for(int i=1;i<10000;i++){
		if((i*(i+1))/2==n){
			cout<<i<<endl;
			return;
		}
		else if((i*(i+1))/2>n+1){
			cout<<i<<endl;
			return;
		}
		else if((i*(i+1)/2)==n+1){
			int u=(i-1)*i;
			u/=2;
			u+=(n-u)*2;
			cout<<i-1+u<<endl;
			return;
		}
	}

}
int main(){
    ll t=1;
    cin>>t;
    while(t--){
    	solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long int lli;
ll mod=1e9+7;
#include<string.h>
ll mod1=998244353;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> os;
#define mp make_pair
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>0;i--)
ll fact[100001];
bool prime[100001];
ll ll_max(ll a,ll b,ll c){
	return max(a,max(b,c));
}
int int_max(int a,int b,int c){
	return max(a,max(b,c));
}
ll ll_min(ll a,ll b,ll c){
	return min(a,min(b,c));
}
int int_min(int a,int b,int c){
	return min(a,min(b,c));
}
ll gcd(ll a,ll b,ll c){
	return __gcd(a,__gcd(b,c));
}
void sieve(int n)
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
double dist(ll i1,ll j1,ll k1,ll i2,ll j2,ll k2){
	double a=pow((i1-i2),2)+pow((j1-j2),2)+pow((k1-k2),2);
	a=sqrt(a);
	return a;
}
bool compare(pair<ll,ll> a,pair<ll,ll> b){
	if(a.first<b.first)
		return true;
	else if(a.first==b.first){
		if(a.second>b.second)
			return true;
		else
			return false;
	}
	else
		return false;
}
void buildTree(int arr[],int tree[], int start,int end,int node){
	if(start==end){
		tree[node]=arr[start];
		return;
	}
	int mid=(start+end)/2;
	buildTree(arr,tree,start,mid,2*node);
	buildTree(arr,tree,mid+1,end,2*node+1);
	tree[node]=tree[2*node]+tree[2*node+1];
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
	if(a.se==b.se)
		return a.fi<b.fi;
    return (a.second < b.second);
}
ll pow(ll a,ll b){
	if(a==1)
		return 1;
	if(b==0)
		return 1;
	ll c=pow(a,b/2);
	ll res=1;
	if(b%2){
		res=(c*c)%mod;
		res*=a;
		res%=mod;
	}
	else
		res=(c*c)%mod;
	return res;
}
int lower_bound1(vector<int> v,int n,int p){
	int l=0;
	int r=n;
	if(v[0]>=p)
		return 0;
	while(l<r){
		int mid=(l+r)/2;
		if(v[mid]<p)
			l=mid+1;
		else if(v[mid]==p){
			if(mid==0)
				r=mid;
			if(v[mid-1]==p)
				r=mid-1;
			else
				r=mid;
		}
		else if(v[mid]>p)
			r=mid;
	}
	return l;
}
void bfs(vector<int> v[],int n,int a1,int b,bool visited[],int &count){
	queue<int> q;
	q.push(a1);
	q.push(b);
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){

		}
	}
}
ll modInv(ll a){
	return pow(a,mod-2)%mod;
}
ll ncr(ll n,ll r){
	ll b=modInv(fact[n-r]);
	ll c=modInv(fact[r]);
	ll a=fact[n]*b;
	a%=mod;
	a*=c;
	a%=mod;
	return a;
}
void dfs(int i,bool visited[],vector<int> v[]){
	for(int j=0;j<v[i].size();j++){
		if(visited[v[i][j]]==false){
			visited[v[i][j]]=true;
			dfs(v[i][j],visited,v);
		}
	}
}
void factorial(ll n){
	fact[0]=1;
    for(ll i=1;i<=n;i++){
    	fact[i]=fact[i-1]*i;
    	fact[i]%=mod;
	}
}
void solve(){
	int n,a,b;
	cin>>a>>b;
	n=abs(a-b);
	if(n==0){
		cout<<0<<endl;
		return;
	}
	for(int i=1;i<10000;i++){
		if((i*(i+1))/2==n){
			cout<<i<<endl;
			return;
		}
		else if((((i*(i+1))/2)-n)%2==0&&(i*(i+1))/2>n){
			cout<<i<<endl;
			return;
		}
	}

}
int main(){
    ll t=1;
    cin>>t;
    while(t--){
    	solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long int lli;
ll mod=1e9+7;
#include<string.h>
ll mod1=998244353;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> os;
#define mp make_pair
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>0;i--)
ll fact[100001];
bool prime[100001];
ll ll_max(ll a,ll b,ll c){
	return max(a,max(b,c));
}
int int_max(int a,int b,int c){
	return max(a,max(b,c));
}
ll ll_min(ll a,ll b,ll c){
	return min(a,min(b,c));
}
int int_min(int a,int b,int c){
	return min(a,min(b,c));
}
ll gcd(ll a,ll b,ll c){
	return __gcd(a,__gcd(b,c));
}
void sieve(int n)
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
double dist(ll i1,ll j1,ll k1,ll i2,ll j2,ll k2){
	double a=pow((i1-i2),2)+pow((j1-j2),2)+pow((k1-k2),2);
	a=sqrt(a);
	return a;
}
bool compare(pair<ll,ll> a,pair<ll,ll> b){
	if(a.first<b.first)
		return true;
	else if(a.first==b.first){
		if(a.second>b.second)
			return true;
		else
			return false;
	}
	else
		return false;
}
void buildTree(int arr[],int tree[], int start,int end,int node){
	if(start==end){
		tree[node]=arr[start];
		return;
	}
	int mid=(start+end)/2;
	buildTree(arr,tree,start,mid,2*node);
	buildTree(arr,tree,mid+1,end,2*node+1);
	tree[node]=tree[2*node]+tree[2*node+1];
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
	if(a.se==b.se)
		return a.fi<b.fi;
    return (a.second < b.second);
}
ll pow(ll a,ll b){
	if(a==1)
		return 1;
	if(b==0)
		return 1;
	ll c=pow(a,b/2);
	ll res=1;
	if(b%2){
		res=(c*c)%mod;
		res*=a;
		res%=mod;
	}
	else
		res=(c*c)%mod;
	return res;
}
int lower_bound1(vector<int> v,int n,int p){
	int l=0;
	int r=n;
	if(v[0]>=p)
		return 0;
	while(l<r){
		int mid=(l+r)/2;
		if(v[mid]<p)
			l=mid+1;
		else if(v[mid]==p){
			if(mid==0)
				r=mid;
			if(v[mid-1]==p)
				r=mid-1;
			else
				r=mid;
		}
		else if(v[mid]>p)
			r=mid;
	}
	return l;
}
void bfs(vector<int> v[],int n,int a1,int b,bool visited[],int &count){
	queue<int> q;
	q.push(a1);
	q.push(b);
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){

		}
	}
}
ll modInv(ll a){
	return pow(a,mod-2)%mod;
}
ll ncr(ll n,ll r){
	ll b=modInv(fact[n-r]);
	ll c=modInv(fact[r]);
	ll a=fact[n]*b;
	a%=mod;
	a*=c;
	a%=mod;
	return a;
}
void dfs(int i,bool visited[],vector<int> v[]){
	for(int j=0;j<v[i].size();j++){
		if(visited[v[i][j]]==false){
			visited[v[i][j]]=true;
			dfs(v[i][j],visited,v);
		}
	}
}
void factorial(ll n){
	fact[0]=1;
    for(ll i=1;i<=n;i++){
    	fact[i]=fact[i-1]*i;
    	fact[i]%=mod;
	}
}
void solve(){
	ll a,b;
	cin>>a>>b;
	ll c=min(a,b);
	ll d=max(a,b);
	a=c;
	b=d;
	b-=a;
	for(int i=0;;i++){
		if(b>=i)
			b-=i;
		else if(b<i){
			b+=i;
		}
		if(b==0){
			cout<<i<<endl;
			return;
		}
	}
}
int main(){
    ll t=1;
    cin>>t;
    while(t--){
    	solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long int lli;
ll mod=1e9+7;
#include<string.h>
ll mod1=998244353;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> os;
#define mp make_pair
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>0;i--)
ll fact[100001];
bool prime[100001];
ll ll_max(ll a,ll b,ll c){
	return max(a,max(b,c));
}
int int_max(int a,int b,int c){
	return max(a,max(b,c));
}
ll ll_min(ll a,ll b,ll c){
	return min(a,min(b,c));
}
int int_min(int a,int b,int c){
	return min(a,min(b,c));
}
ll gcd(ll a,ll b,ll c){
	return __gcd(a,__gcd(b,c));
}
void sieve(int n)
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
double dist(ll i1,ll j1,ll k1,ll i2,ll j2,ll k2){
	double a=pow((i1-i2),2)+pow((j1-j2),2)+pow((k1-k2),2);
	a=sqrt(a);
	return a;
}
bool compare(pair<ll,ll> a,pair<ll,ll> b){
	if(a.first<b.first)
		return true;
	else if(a.first==b.first){
		if(a.second>b.second)
			return true;
		else
			return false;
	}
	else
		return false;
}
void buildTree(int arr[],int tree[], int start,int end,int node){
	if(start==end){
		tree[node]=arr[start];
		return;
	}
	int mid=(start+end)/2;
	buildTree(arr,tree,start,mid,2*node);
	buildTree(arr,tree,mid+1,end,2*node+1);
	tree[node]=tree[2*node]+tree[2*node+1];
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
	if(a.se==b.se)
		return a.fi<b.fi;
    return (a.second < b.second);
}
ll pow(ll a,ll b){
	if(a==1)
		return 1;
	if(b==0)
		return 1;
	ll c=pow(a,b/2);
	ll res=1;
	if(b%2){
		res=(c*c)%mod;
		res*=a;
		res%=mod;
	}
	else
		res=(c*c)%mod;
	return res;
}
int lower_bound1(vector<int> v,int n,int p){
	int l=0;
	int r=n;
	if(v[0]>=p)
		return 0;
	while(l<r){
		int mid=(l+r)/2;
		if(v[mid]<p)
			l=mid+1;
		else if(v[mid]==p){
			if(mid==0)
				r=mid;
			if(v[mid-1]==p)
				r=mid-1;
			else
				r=mid;
		}
		else if(v[mid]>p)
			r=mid;
	}
	return l;
}
void bfs(vector<int> v[],int n,int a1,int b,bool visited[],int &count){
	queue<int> q;
	q.push(a1);
	q.push(b);
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){

		}
	}
}
ll modInv(ll a){
	return pow(a,mod-2)%mod;
}
ll ncr(ll n,ll r){
	ll b=modInv(fact[n-r]);
	ll c=modInv(fact[r]);
	ll a=fact[n]*b;
	a%=mod;
	a*=c;
	a%=mod;
	return a;
}
void dfs(int i,bool visited[],vector<int> v[]){
	for(int j=0;j<v[i].size();j++){
		if(visited[v[i][j]]==false){
			visited[v[i][j]]=true;
			dfs(v[i][j],visited,v);
		}
	}
}
void factorial(ll n){
	fact[0]=1;
    for(ll i=1;i<=n;i++){
    	fact[i]=fact[i-1]*i;
    	fact[i]%=mod;
	}
}
void solve(){
	int n,a,b;
	cin>>a>>b;
	n=abs(a-b);
	if(n==0){
		cout<<0<<endl;
		return;
	}
	for(int i=1;i<10000;i++){
		if((i*(i+1))/2==n){
			cout<<i<<endl;
			return;
		}
		else if((i*(i+1))/2>n+1){
			cout<<i<<endl;
			return;
		}
		else if((i*(i+1)/2)==n+1){
			cout<<i+1<<endl;
			return;
		}
	}

}
int main(){
    ll t=1;
    cin>>t;
    while(t--){
    	solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long int lli;
ll mod=1e9+7;
#include<string.h>
ll mod1=998244353;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> os;
#define mp make_pair
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>0;i--)
ll fact[100001];
bool prime[100001];
ll ll_max(ll a,ll b,ll c){
	return max(a,max(b,c));
}
int int_max(int a,int b,int c){
	return max(a,max(b,c));
}
ll ll_min(ll a,ll b,ll c){
	return min(a,min(b,c));
}
int int_min(int a,int b,int c){
	return min(a,min(b,c));
}
ll gcd(ll a,ll b,ll c){
	return __gcd(a,__gcd(b,c));
}
void sieve(int n)
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
double dist(ll i1,ll j1,ll k1,ll i2,ll j2,ll k2){
	double a=pow((i1-i2),2)+pow((j1-j2),2)+pow((k1-k2),2);
	a=sqrt(a);
	return a;
}
bool compare(pair<ll,ll> a,pair<ll,ll> b){
	if(a.first<b.first)
		return true;
	else if(a.first==b.first){
		if(a.second>b.second)
			return true;
		else
			return false;
	}
	else
		return false;
}
void buildTree(int arr[],int tree[], int start,int end,int node){
	if(start==end){
		tree[node]=arr[start];
		return;
	}
	int mid=(start+end)/2;
	buildTree(arr,tree,start,mid,2*node);
	buildTree(arr,tree,mid+1,end,2*node+1);
	tree[node]=tree[2*node]+tree[2*node+1];
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
	if(a.se==b.se)
		return a.fi<b.fi;
    return (a.second < b.second);
}
ll pow(ll a,ll b){
	if(a==1)
		return 1;
	if(b==0)
		return 1;
	ll c=pow(a,b/2);
	ll res=1;
	if(b%2){
		res=(c*c)%mod;
		res*=a;
		res%=mod;
	}
	else
		res=(c*c)%mod;
	return res;
}
int lower_bound1(vector<int> v,int n,int p){
	int l=0;
	int r=n;
	if(v[0]>=p)
		return 0;
	while(l<r){
		int mid=(l+r)/2;
		if(v[mid]<p)
			l=mid+1;
		else if(v[mid]==p){
			if(mid==0)
				r=mid;
			if(v[mid-1]==p)
				r=mid-1;
			else
				r=mid;
		}
		else if(v[mid]>p)
			r=mid;
	}
	return l;
}
void bfs(vector<int> v[],int n,int a1,int b,bool visited[],int &count){
	queue<int> q;
	q.push(a1);
	q.push(b);
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){

		}
	}
}
ll modInv(ll a){
	return pow(a,mod-2)%mod;
}
ll ncr(ll n,ll r){
	ll b=modInv(fact[n-r]);
	ll c=modInv(fact[r]);
	ll a=fact[n]*b;
	a%=mod;
	a*=c;
	a%=mod;
	return a;
}
void dfs(int i,bool visited[],vector<int> v[]){
	for(int j=0;j<v[i].size();j++){
		if(visited[v[i][j]]==false){
			visited[v[i][j]]=true;
			dfs(v[i][j],visited,v);
		}
	}
}
void factorial(ll n){
	fact[0]=1;
    for(ll i=1;i<=n;i++){
    	fact[i]=fact[i-1]*i;
    	fact[i]%=mod;
	}
}
void solve(){
	int n,a,b;
	cin>>a>>b;
	n=abs(a-b);
	if(n==0){
		cout<<0<<endl;
		return;
	}
	for(int i=1;i<10000;i++){
		if((i*(i+1))/2==n){
			cout<<i<<endl;
			return;
		}
		else if((i*(i+1))/2>n){
			break;
		}
	}
	cout<<n<<endl;
}
int main(){
    ll t=1;
    cin>>t;
    while(t--){
    	solve();
	}
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1e9 + 7;
const int N = (int)(3e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int t, a, b, mn = 1e9;

void rec(int x, int y,int add)
{
	if (add > abs(a - b) + 10)return;
	if (x == y)
	{
		mn = min(mn, add);
	}
	//cout << x << ' ' << y << endl;
	rec(x + add, y, add + 1);
	rec(x, y + add, add + 1);
}
int main()
{
	inp();
	cin >> t;

	/*for (int i = 1; i < 30; i++)
	{
		rec(a, i, 1);
		cout << mn - 1 << ' ' << i << endl;
		mn = 1e9;
	}*/

	while (t--)
	{
		scanf("%d%d", &a, &b);
		int x = 1, ans = 0;
		ll c = abs(a - b);

		for (ll i = 0; i <= 1e9 + 10; i++)
		{
			if (i * (i + 1)/2 == c)
			{
				cout << i << endl;
				break;
			}
			ll v = i * (i + 1) / 2;
			if (v > c)
			{
				if (v - c % 2)
				{
					cout << i + 1 << endl;
				}
				else
				{
					cout << i + 2 << endl;
				}
				break;
			}
		}

	}
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1e9 + 7;
const int N = (int)(3e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int t, a, b;

int main()
{
	inp();
	cin >> t;

	while (t--)
	{
		scanf("%d%d", &a, &b);
		if (a < b)swap(a, b);
		ll c = a - b;

		for (ll i = 0; i <= 1e9 + 10; i++)
		{
			ll v = i * (i + 1) / 2;

			if (v == c)
			{
				cout << i << endl;
				break;
			}

			if (v > c && v % 2 == c % 2)
			{
				cout << i << endl;
				break;
			}
		}

	}
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1e9 + 7;
const int N = (int)(3e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int t, a, b;

int main()
{
	inp();
	cin >> t;

	while (t--)
	{
		scanf("%d%d", &a, &b);
		int x = 1, ans = 0;
		ll c = abs(a - b), add = 0;

		for (ll i = 0; i <= 1e9 + 10; i++)
		{
			ll v = i * (i + 1) / 2;
			if (v > c)
			{
				c -= i * (i - 1) / 2;
				add = i * (i - 1) / 2;
				ans = i - 1;
				break;
			}
		}

		if (a < b)swap(a, b);
		cout << ans + (a - (b + add)) * 2 << endl;
	}
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1e9 + 7;
const int N = (int)(3e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int t, a, b;

int main()
{
	inp();
	cin >> t;

	while (t--)
	{
		scanf("%d%d", &a, &b);
		int x = 1, ans = 0;
		ll c = abs(a - b), add = 0;

		for (ll i = 0; i <= 1e9 + 10; i++)
		{
			ll v = i * (i + 1) / 2;
			if (v > c)
			{
				c -= i * (i - 1) / 2;
				add = i * (i - 1) / 2;
				ans = i - 1;
				break;
			}
		}

		if (a < b)swap(a, b);
		b += add;

		ll gt = min((b + ans + 1 - a) * 2, (a - b) * 2) + ans;

		cout << gt << endl;
	}
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1e9 + 7;
const int N = (int)(3e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int t, a, b;

int main()
{
	inp();
	cin >> t;

	while (t--)
	{
		scanf("%d%d", &a, &b);
		int x = 1, ans = 0;
		ll c = abs(a - b);

		for (ll i = 0; i <= 1e9 + 10; i++)
		{
			if (i * (i + 1) / 2 == c)
			{
				cout << i << endl;
				break;
			}

			if (i * (i + 1)/2 > c && (i * (i + 1) / 2) % 2 == 0)
			{
				cout << i << endl;
				break;
			}
		}

	}
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1e9 + 7;
const int N = (int)(3e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int t, a, b, mn = 1e9;

void rec(int x, int y,int add)
{
	if (add > abs(a - b) + 20)return;
	if (x == y)
	{
		mn = min(mn, add);
	}

	rec(x + add, y, add + 1);
	rec(x, y + add, add + 1);
}
int main()
{
	inp();
	cin >> t;

	while (t--)
	{
		scanf("%d%d", &a, &b);
		if (a < b)swap(a, b);
		ll c = a - b;

		for (ll i = 0; i <= 1e9 + 10; i++)
		{
			ll v = i * (i + 1) / 2;

			if (v == c)
			{
				cout << i << endl;
				break;
			}

			if (v > c)
			{
				if ((v - c) % 2 == 0)
				{
					cout << i << endl;
				}
				else
				{
					cout << i + 1 << endl;
				}
				break;
			}
		}

	}
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1e9 + 7;
const int N = (int)(3e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int t, a, b;

int main()
{
	inp();
	cin >> t;

	while (t--)
	{
		scanf("%d%d", &a, &b);
		ll c = abs(a - b);
		int x = 1, ans = 0;
		while (a != b)
		{
			if (a > b)
			{
				if (b + x <= a)
					b += x;
				else
					a += x;
			}
			else
			{
				if (a+ x <= b)
					a += x;
				else
					b += x;
			}
			x++;
			ans++;
		}
		cout << ans << endl;
	}
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1e9 + 7;
const int N = (int)(3e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int t, a, b;

int main()
{
	inp();
	cin >> t;

	while (t--)
	{
		scanf("%d%d", &a, &b);
		ll c = abs(a - b);
		for (ll i = 0; i <= 1e9 + 10; i++)
		{
			ll v = i * (i + 1) / 2;
			if (v == c)
			{
				cout << i << endl;
				break;
			}
			else if (v > c)
			{
				cout << i + 1 << endl;
				break;
			}
		}
	}
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1e9 + 7;
const int N = (int)(3e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int t, a, b, mn = 1e9;

void rec(int x, int y,int add)
{
	if (add > abs(a - b) + 20)return;
	if (x == y)
	{
		mn = min(mn, add);
	}
	//cout << x << ' ' << y << endl;
	rec(x + add, y, add + 1);
	rec(x, y + add, add + 1);
}
int main()
{
	inp();
	cin >> t;

	/*for (int i = 1; i < 50; i++)
	{
		rec(a, i, 1);
		cout << mn - 1 << ' ' << i << endl;
		mn = 1e9;
	}*/

	while (t--)
	{
		scanf("%d%d", &a, &b);
		ll c = abs(a - b);

		for (ll i = 0; i <= 1e9 + 10; i++)
		{
			ll v = i * (i + 1) / 2;

			if (v == c)
			{
				cout << i << endl;
				break;
			}

			if (v > c)
			{
				if ((v - c) % 2 == 0)
				{
					cout << i  << endl;
				}
				else
				{
					cout << i + 1 << endl;
				}
				break;
			}
		}

	}
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1e9 + 7;
const int N = (int)(3e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int t, a, b, mn = 1e9;

void rec(int x, int y,int add)
{
	if (add > abs(a - b) + 20)return;
	if (x == y)
	{
		mn = min(mn, add);
	}

	rec(x + add, y, add + 1);
	rec(x, y + add, add + 1);
}
int main()
{
	inp();
	cin >> t;

	while (t--)
	{
		scanf("%d%d", &a, &b);
		if (a < b)swap(a, b);
		ll c = a - b;

		for (ll i = 0; i <= 1e9 + 10; i++)
		{
			ll v = i * (i + 1) / 2;

			if (v == c)
			{
				cout << i << endl;
				break;
			}

			if (v > c)
			{
				if ((v - c) % 2 == i % 2)
				{
					cout << i << endl;
				}
				else
				{
					cout << i + 1 << endl;
				}
				break;
			}
		}

	}
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end()
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

#ifndef ONLINE_JUDGE
#define scanf scanf_s
#endif

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 1e9 + 7;
const int N = (int)(3e5) + 1;

void inp()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "inp.txt", "r", stdin);
#endif
}

void out()
{
#ifndef ONLINE_JUDGE
	FILE* stream;
	freopen_s(&stream, "out.txt", "w", stdout);
#endif
}

ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int t, a, b;

int main()
{
	inp();
	cin >> t;

	while (t--)
	{
		scanf("%d%d", &a, &b);
		if (a < b)swap(a, b);
		ll c = a - b;

		for (ll i = 0; i <= 1e9 + 10; i++)
		{
			ll v = i * (i + 1) / 2;

			if (v == c)
			{
				cout << i << endl;
				break;
			}

			if (v > c)
			{
				if (i % 2)
				{
					cout << i << endl;
				}
				else
				{
					cout << i + 1 << endl;
				}
				break;
			}
		}

	}
}


#include <iostream>
#include <iostream>
#include <utility>
#include <queue>
#include <vector>
#include <cstring>
#include <iterator>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <string>
#include <deque>
#include <algorithm>
#define endl "\n"
#define pb push_back
#define ll long long int
using namespace  std;
ll mod=1000000007;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin>>t;
  while(t--)
  {
    ll a,b;
    cin>>a>>b;
    if(b<a)swap(a,b);
    ll x=(-1+sqrt(1+8*(b-a)))/2;
    ll y=x;
    x=(x*(x+1))/2;
    a+=x;
    cout<<y+2*(b-a)<<endl;
  }
  return 0;
}


#include <iostream>
#include <cmath>
#include<algorithm>
using namespace std;
int main() {
long long int t;
cin>>t;
while(t--)
{
long long int a,b;
cin>>a>>b;
long long int ans=0;
long long int sum=a+b;
long long int i=max(a,b);
long long int j=min(a,b);
long long int v=i-j;
while(true)
{

    float s= sqrt(1+8*v);
    if(floor(s)!=ceil(s))
    v+=2;
    else
    {
        ans=((int)s-1)/2;
        break;
    }

}
cout<<ans<<endl;
}
    return 0;
}


#include <iostream>
#include <iostream>
#include <utility>
#include <queue>
#include <vector>
#include <cstring>
#include <iterator>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <string>
#include <deque>
#include <algorithm>
#define endl "\n"
#define pb push_back
#define ll long long int
using namespace  std;
ll mod=1000000007;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin>>t;
  while(t--)
  {
    int a,b;
    cin>>a>>b;
    if(b<a)swap(a,b);
    int x=(-1+sqrt(1+8*(b-a)))/2;
    int y=x;
    x=(x*(x+1))/2;
    a+=x;
    cout<<y+2*(b-a)<<endl;
  }
  return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int a,b;
cin>>a>>b;
int x=min(a,b);
int y=max(a,b);
int ans=0;
int i=0;
int j=1;
while(x!=y)
{
    if(y-x>=i+1)
    {
        ans++;
        x+=j;
        i++;
        j++;
    }
    else
    {
        ans++;
        y+=j;
        i++;
        j++;

    }
}
cout<<ans<<endl;
}
    return 0;
}


#include <iostream>
#include <iostream>
#include <utility>
#include <queue>
#include <vector>
#include <cstring>
#include <iterator>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <string>
#include <deque>
#include <algorithm>
#define endl "\n"
#define pb push_back
#define ll long long int
using namespace  std;
ll mod=1000000007;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin>>t;
  while(t--)
  {
    ll a,b;
    cin>>a>>b;
    if(a==b){cout<<"0"<<endl;continue;}
   ll k=1;
   while(1)
   {
     ll x=((k*(k+1))/2+a+b);
     if(x%2==0&&x/2>=max(a,b)){cout<<k<<endl;break;}
     k++;
   }

  }
  return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include<algorithm>
using namespace std;
int main() {
long long int t;
cin>>t;
while(t--)
{
long long int a,b;
cin>>a>>b;
long long int ans=0;
long long int sum=a+b;
long long int i=max(a,b);
long long int v=2*i-sum;
while(true)
{

    float s= sqrt(1+8*v);
    if(floor(s)!=ceil(s))
    v+=2;
    else
    {
        ans=((int)s-1)/2;
        break;
    }

}
cout<<ans<<endl;
}
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
using namespace std;
int main() {
long long int t;
cin>>t;
while(t--)
{
long long int a,b;
cin>>a>>b;
long long int x=min(a,b);
long long int y=max(a,b);
long long int ans=0;
long long int i=0;
long long int j=1;
while(x!=y)
{
    if(y-x>=i+1)
    {
        ans++;
        x+=j;
        i++;
        j++;
    }
    else
    {
        ans++;
        y+=j;
        i++;
        j++;

    }
}
cout<<ans<<endl;
}
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include<algorithm>
using namespace std;
int main() {
long long int t;
cin>>t;
while(t--)
{
long long int a,b;
cin>>a>>b;
long long int ans=0;
long long int sum=a+b;
long long int i=max(a,b);
long long int j=min(a,b);
long long int v=i-j;
while(true)
{

    float s= sqrt(1+8*v);
    if(floor(s)!=ceil(s))
    v+=2;
    else
    {
        ans=((int)s-1)/2;
        break;
    }

}
cout<<ans<<endl;
}
    return 0;
}


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

int main(){
	int t;
	cin>>t;
	while(t--){
		long long int a,b;
		cin>>a>>b;
		long long int a1=min(a,b),b1=max(a,b);
		if(a==b)
		 cout<<0<<"\n";
		else{
			int r=sqrt(b1-a1);
			long long i;
			for(i=r-1;i<100000;i++){
				if((i*(i+1))/2>=(b1-a1))
				 break;
			}
			if((i*(i+1))/2==(b1-a1))
			 cout<<i<<"\n";
			else{
				int x1=(i*(i+1))/2-(b1-a1);
				int x2=(b1-a1)-(i*(i-1))/2;
				int count=0,count1=0;
				while(x2){
					int r=sqrt(x2);
					x2=x2-(r*r);
					if(r==1)
					 count+=2;
					else
					 count+=r;
			   }
			   while(x1){
				   int r=sqrt(x1);
				   x1=x1-(r*r);
				   if(r==1)
				    count1+=1;
				   else
				    count1+=r;
			 }
			 if(count<=count1)
			  cout<<count+i-1<<"\n";
			 else
			  cout<<count1+i<<"\n";

			}
	   }
	}
}


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

signed main(){
    int t;
    cin>>t;
    while(t--){
        int a,b;
        cin>>a>>b;
        if(a==b){
            cout<<0<<endl;
        }
        else{
            int a1=min(a,b);
            int b1=max(a,b);
            int y=b1-a1;
            int j=1,i=0;
            for(;;i++){
                int y2=y+2*(i),q=0;
                for(;;j++){
                    int y1=(j*(j+1))/2;
                    if(y1>y2)
                     {
                         break;
                     }
                     else if(y1==y2){
                         q=1;
                         cout<<j<<endl;
                         break;
                     }
                }
                if(q==1){
                    break;
                }
            }
        }
    }
}


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

int main(){
	int t;
	cin>>t;
	while(t--){
		long long int a,b;
		cin>>a>>b;
		long long int a1=min(a,b),b1=max(a,b);
		if(a==b)
		 cout<<0<<"\n";
		else{
			int r=sqrt(b1-a1);
			long long i;
			for(i=r-1;i<100000;i++){
				if((i*(i+1))/2>=(b1-a1))
				 break;
			}
			if((i*(i+1))/2==(b1-a1))
			 cout<<i<<"\n";
			else{
				int x1=(i*(i+1))/2-(b1-a1);
				int x2=(b1-a1)-(i*(i-1))/2;
				int count=0,count1=0;
				while(x2){
					int r=sqrt(x2);
					x2=x2-(r*r);
					 count+=r*2;
			   }
			   while(x1){
				   int r=sqrt(x1);
				   x1=x1-(r*r);

				    count1+=r*2;
			 }
			 if(count<=count1)
			  cout<<count+i-1<<"\n";
			 else
			  cout<<count1+i<<"\n";

			}
	   }
	}
}


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

int main(){
	int t;
	cin>>t;
	while(t--){
		long long int a,b;
		cin>>a>>b;
		long long int a1=min(a,b),b1=max(a,b);
		if(a==b)
		 cout<<0<<"\n";
		else{
			//int r=sqrt(b1-a1);
			long long i;
			for(i=1;i<100000;i++){
				if((i*(i+1))/2>=(b1-a1))
				 break;
			}
			if((i*(i+1))/2==(b1-a1))
			 cout<<i<<"\n";
			else{
				long long int x1=(i*(i+1))/2-(b1-a1);
				long long int x2=(b1-a1)-(i*(i-1))/2;
				long long int count=0,count1=0;
				while(x2){
					long long int r=sqrt(x2);
					x2=x2-(r*r);
					 count+=r*2;
			   }
			   while(x1){
				   long long int r=sqrt(x1);
				   x1=x1-(r*r);

				    count1+=r*2;
			 }
			 cout<<min(count1+i,count+i-1)<<"\n";

			}
	   }
	}
}


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

int main(){
	int t;
	cin>>t;
	while(t--){
		long long int a,b;
		cin>>a>>b;
		long long int a1=min(a,b),b1=max(a,b);
		if(a==b)
		 cout<<0<<"\n";
		else{
			//int r=sqrt(b1-a1);
			long long i;
			for(i=1;i<100000;i++){
				if((i*(i+1))/2>=(b1-a1))
				 break;
			}
			if((i*(i+1))/2==(b1-a1))
			 cout<<i<<"\n";
			else{
				int x1=(i*(i+1))/2-(b1-a1);
				int x2=(b1-a1)-(i*(i-1))/2;
				cout<<min(i-1+x2*2,i+x1*2)<<"\n";

			 }
	   }
	}
}


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

signed main(){
    int t;
    cin>>t;
    while(t--){
        int a,b;
        cin>>a>>b;
        if(a==b){
            cout<<0<<endl;
        }
        else{
            int a1=min(a,b);
            int b1=max(a,b);
            int y=b1-a1;
            for(int i=b1;;i++){
                int y2=y+2*(i-b1),q=0;
                for(int j=1;;j++){
                    int y1=(j*(j+1))/2;
                    if(y1>y2)
                     {
                         break;
                     }
                     else if(y1==y2){
                         q=1;
                         cout<<j<<endl;
                         break;
                     }
                }
                if(q==1){
                    break;
                }
            }
        }
    }
}


#include <bits/stdc++.h>

// loops
#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define travR(it, ctr) for(auto it=ctr.rbegin(); it!=ctr.rend(); it++)

// I/O
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define p(x) cout<<x<<"\n"
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define lbr cout<<"\n"

// container and contants
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define hell (int)1e9
#define ms(x) memset(x, 0, sizeof(x))
// namespaces
using namespace std;

// typedefs
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

typedef map<int, int> mii;
typedef unsigned long long ull;
typedef priority_queue<int> pq;

// global constants
const int inf=1e9+7;
#define M 1000000007

#define ll long long
ll power(ll x,ll y)
{
    ll res = 1;
    x = x % M;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % M;

        y = y>>1;
        x = (x*x) % M;
    }
    return res;
}
map<ll,vector<ll>> adj;
map<ll,vector<ll>> connect;
map<ll,ll> visited;

void dfs(ll curr,ll ind)
{
    visited[curr]=1;
    connect[ind].pb(curr);

    for (auto x:adj[curr])
    {
        if (visited[x]!=1)
        {
            dfs(x,ind);
        }

    }

}

int main()
{

 ll t;
 cin>>t;

 while(t--)
 {
    ll a,b;
    cin>>a>>b;

    //now a>b
    ll diff=abs(a-b);
    diff=2*diff;
    //binary search
    ll flag=0,num=0,near=0;

    ll d=sqrt(diff);

    //cout<<"sqrt "<<d<<" "<<diff<<" "<<d*(d+1)<<endl;
    while(1)
    {
        if (d*(d+1)>=diff)
        break;

        d++;
    }

    if (d*(d+1)==diff)
    p(d);
    else
    p(d+1);
 }

    return 0;
}


#include <bits/stdc++.h>

// loops
#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define travR(it, ctr) for(auto it=ctr.rbegin(); it!=ctr.rend(); it++)

// I/O
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define p(x) cout<<x<<"\n"
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define lbr cout<<"\n"

// container and contants
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define hell (int)1e9
#define ms(x) memset(x, 0, sizeof(x))
// namespaces
using namespace std;

// typedefs
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

typedef map<int, int> mii;
typedef unsigned long long ull;
typedef priority_queue<int> pq;

// global constants
const int inf=1e9+7;
#define M 1000000007

#define ll long long
ll power(ll x,ll y)
{
    ll res = 1;
    x = x % M;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % M;

        y = y>>1;
        x = (x*x) % M;
    }
    return res;
}
map<ll,vector<ll>> adj;
map<ll,vector<ll>> connect;
map<ll,ll> visited;

void dfs(ll curr,ll ind)
{
    visited[curr]=1;
    connect[ind].pb(curr);

    for (auto x:adj[curr])
    {
        if (visited[x]!=1)
        {
            dfs(x,ind);
        }

    }

}

ll a[200005],b[200005];

int main()
{
    ll t;cin>>t;
 while(t--){
  ll a,b;
  cin>>a>>b;
  ll n,k;
  ll diff=abs(b-a);
  n=100005;
  k=diff;
  //cin>>n>>k;
  ll flag=0;

 //cout<<a<<" "<<b<<endl;
 //if (diff==0){cout<<0<<endl;continue;}

 ll ans=-1,mx,ka=k;
 ll low=0,high=n;
  while(low<=high){
      ll mid=low+high;mid/=2;
      ll ta=mid*(mid+1);ta/=2;
    // cout<<low<<" "<<mid<<" "<<high<<endl;
      if (ta>ka){
          high=mid-1;
          mx=max(mx,mid);
      }
      else if (ta<=ka){
          low=mid+1;
          ans=mid;
      }
  }

    for (ll i=ans;i<=ans+30;i++){
        if ((i*(i+1))/2-diff<0)
        continue;

        if (((i*(i+1))/2-diff)%2==0){
            ans=i;
            break;
        }

    }

  p(ans);

 }
    return 0;
}


#include <bits/stdc++.h>

// loops
#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define travR(it, ctr) for(auto it=ctr.rbegin(); it!=ctr.rend(); it++)

// I/O
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define p(x) cout<<x<<"\n"
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define lbr cout<<"\n"

// container and contants
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define hell (int)1e9
#define ms(x) memset(x, 0, sizeof(x))
// namespaces
using namespace std;

// typedefs
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

typedef map<int, int> mii;
typedef unsigned long long ull;
typedef priority_queue<int> pq;

// global constants
const int inf=1e9+7;
#define M 1000000007

#define ll long long
ll power(ll x,ll y)
{
    ll res = 1;
    x = x % M;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % M;

        y = y>>1;
        x = (x*x) % M;
    }
    return res;
}
map<ll,vector<ll>> adj;
map<ll,vector<ll>> connect;
map<ll,ll> visited;

void dfs(ll curr,ll ind)
{
    visited[curr]=1;
    connect[ind].pb(curr);

    for (auto x:adj[curr])
    {
        if (visited[x]!=1)
        {
            dfs(x,ind);
        }

    }

}

int main()
{

 ll t;
 cin>>t;

 while(t--)
 {
    ll a,b;
    cin>>a>>b;

    if (a<b)
    swap(a,b);

    //now a>b
    ll diff=abs(a-b);
    diff*=2;
    //binary search
    ll flag=0,num=0,near=0;
    for (ll i=2;i<=sqrt(diff);i++)
    {
        if (diff%i==0)
        {
            if (diff/i-i==1)
            {
                flag=1;num=i;
            }
            else
            near=i;
        }
    }

    if (flag||diff==0)
    p(num);
    else
    p(near+1);

 }

    return 0;
}


#include <bits/stdc++.h>

// loops
#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define travR(it, ctr) for(auto it=ctr.rbegin(); it!=ctr.rend(); it++)

// I/O
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define p(x) cout<<x<<"\n"
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define lbr cout<<"\n"

// container and contants
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define hell (int)1e9
#define ms(x) memset(x, 0, sizeof(x))
// namespaces
using namespace std;

// typedefs
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

typedef map<int, int> mii;
typedef unsigned long long ull;
typedef priority_queue<int> pq;

// global constants
const int inf=1e9+7;
#define M 1000000007

#define ll long long
ll power(ll x,ll y)
{
    ll res = 1;
    x = x % M;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % M;

        y = y>>1;
        x = (x*x) % M;
    }
    return res;
}
map<ll,vector<ll>> adj;
map<ll,vector<ll>> connect;
map<ll,ll> visited;

void dfs(ll curr,ll ind)
{
    visited[curr]=1;
    connect[ind].pb(curr);

    for (auto x:adj[curr])
    {
        if (visited[x]!=1)
        {
            dfs(x,ind);
        }

    }

}

int main()
{

 ll t;
 cin>>t;

 while(t--)
 {
    ll a,b;
    cin>>a>>b;

    //now a>b
    ll diff=abs(a-b);
    diff=2*diff;
    //binary search
    ll flag=0,num=0,near=0;

    ll d=sqrt(diff);

  ll t=0;//cout<<d<<" "<<d*(d+1)<<" "<<diff<<endl;

     if (((d*(d+1))-diff)/4>0)
    p(d);
    else
    p(d+1);
 }

    return 0;
}


#include <bits/stdc++.h>

// loops
#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define travR(it, ctr) for(auto it=ctr.rbegin(); it!=ctr.rend(); it++)

// I/O
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define p(x) cout<<x<<"\n"
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define lbr cout<<"\n"

// container and contants
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define hell (int)1e9
#define ms(x) memset(x, 0, sizeof(x))
// namespaces
using namespace std;

// typedefs
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

typedef map<int, int> mii;
typedef unsigned long long ull;
typedef priority_queue<int> pq;

// global constants
const int inf=1e9+7;
#define M 1000000007

#define ll long long
ll power(ll x,ll y)
{
    ll res = 1;
    x = x % M;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % M;

        y = y>>1;
        x = (x*x) % M;
    }
    return res;
}
map<ll,vector<ll>> adj;
map<ll,vector<ll>> connect;
map<ll,ll> visited;

void dfs(ll curr,ll ind)
{
    visited[curr]=1;
    connect[ind].pb(curr);

    for (auto x:adj[curr])
    {
        if (visited[x]!=1)
        {
            dfs(x,ind);
        }

    }

}

ll a[200005],b[200005];

int main()
{
    ll t;cin>>t;
 while(t--){
  ll a,b;
  cin>>a>>b;
  ll n,k;
  ll diff=abs(b-a);
  n=100005;
  k=diff;
  //cin>>n>>k;
  ll flag=0;

 //cout<<a<<" "<<b<<endl;
 //if (diff==0){cout<<0<<endl;continue;}

 ll ans=-1,mx,ka=k;
 ll low=0,high=n;
  while(low<=high){
      ll mid=low+high;mid/=2;
      ll ta=mid*(mid+1);ta/=2;
    // cout<<low<<" "<<mid<<" "<<high<<endl;
      if (ta>ka){
          high=mid-1;
          mx=max(mx,mid);
      }
      else if (ta<=ka){
          low=mid+1;
          ans=mid;
      }
  }

    for (ll i=ans;i<=ans+5;i++){
        if ((i*(i+1))/2-diff<0)
        continue;

        if (((i*(i+1))/2-diff)%2==0){
            ans=i;
            break;
        }

    }

  p(ans);

 }
    return 0;
}


#include <bits/stdc++.h>

// loops
#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define travR(it, ctr) for(auto it=ctr.rbegin(); it!=ctr.rend(); it++)

// I/O
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define p(x) cout<<x<<"\n"
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define lbr cout<<"\n"

// container and contants
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define hell (int)1e9
#define ms(x) memset(x, 0, sizeof(x))
// namespaces
using namespace std;

// typedefs
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

typedef map<int, int> mii;
typedef unsigned long long ull;
typedef priority_queue<int> pq;

// global constants
const int inf=1e9+7;
#define M 1000000007

#define ll long long
ll power(ll x,ll y)
{
    ll res = 1;
    x = x % M;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % M;

        y = y>>1;
        x = (x*x) % M;
    }
    return res;
}
map<ll,vector<ll>> adj;
map<ll,vector<ll>> connect;
map<ll,ll> visited;

void dfs(ll curr,ll ind)
{
    visited[curr]=1;
    connect[ind].pb(curr);

    for (auto x:adj[curr])
    {
        if (visited[x]!=1)
        {
            dfs(x,ind);
        }

    }

}

int main()
{

 ll t;
 cin>>t;

 while(t--)
 {
    ll a,b;
    cin>>a>>b;

    //now a>b
    ll diff=abs(a-b);
    diff=2*diff;
    //binary search
    ll flag=0,num=0,near=0;

    ll d=sqrt(diff);

   // cout<<"sqrt "<<d<<" "<<diff<<" "<<d*(d+1)<<endl;

    if (d*(d+1)==diff)
    p(d);
    else
    p(d+1);

 }

    return 0;
}