#include <bits/stdc++.h>
using namespace std;
inline long long int modadd(long long int n, long long int m) {
  long long int sum = ((n + m) % 1000000007 + 1000000007) % 1000000007;
  return sum;
}
inline long long int modsub(long long int n, long long int m) {
  long long int diff =
      ((n - m + 1000000007) % 1000000007 + 1000000007) % 1000000007;
  return diff;
}
inline long long int modpro(long long int n, long long int m) {
  long long int pro = ((n * m) % 1000000007 + 1000000007) % 1000000007;
  return pro;
}
inline long long int pow(int x, int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
inline long long int powmod(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = modpro(res, x);
    y = y >> 1;
    x = modpro(x, x);
  }
  return res;
}
bool sortbysec(const pair<string, int> &a, const pair<string, int> &b) {
  return (a.second < b.second);
}
long long int min(long long int a, long long int b) {
  if (a > b) {
    return b;
  }
  return a;
}
long long int max(long long int a, long long int b) {
  if (a > b) {
    return a;
  }
  return b;
}
vector<long long int> v;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int test = 1;
  cin >> test;
  long long int wow = test;
  long long int sum = 0;
  for (int i = 0; i < 100000; i++) {
    sum += i;
    v.push_back(sum);
    if (sum > 1000080000) break;
  }
  while (test--) {
    long long int x, y;
    cin >> x >> y;
    long long int ans;
    long long int diff = abs(x - y);
    long long int z = lower_bound(v.begin(), v.end(), diff) - v.begin();
    long long int p, q;
    if (v[z] % 2 == diff % 2) {
      p = (v[z] - diff) / 2;
      q = (diff + v[z]) / 2;
      long long int dff = p + q;
      ans = lower_bound(v.begin(), v.end(), dff) - v.begin();
    } else if (v[z + 1] % 2 == diff % 2) {
      p = (v[z + 1] - diff) / 2;
      q = (diff + v[z + 1]) / 2;
      long long int dff = p + q;
      ans = lower_bound(v.begin(), v.end(), dff) - v.begin();
    } else {
      p = (v[z + 2] - diff) / 2;
      q = (diff + v[z + 2]) / 2;
      long long int dff = p + q;
      ans = lower_bound(v.begin(), v.end(), dff) - v.begin();
    }
    cout << ans << endl;
  }
  return 0;
}
