#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long a, b;
const long long sz = 1e6;
const long long inf = 1e12;
vector<long long> keep;
long long get(long long n) { return n * (n + 1) / 2; }
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(9);
  for (long long i = 0; i <= sz; ++i) {
    keep.push_back(get(i));
  }
  long long t;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    long long diff = b - a;
    long long ind = lower_bound(keep.begin(), keep.end(), diff) - keep.begin();
    long long ans = inf;
    for (long long i = ind; i <= sz; ++i) {
      long long cur = a + b + keep[i];
      if (cur % 2 == 0) {
        ans = i;
        break;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
