#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void sample() {}
long long int* read(long long int n) {
  long long int* arr = new long long int[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  return arr;
}
bool ok(int res, int d) {
  long long sum = res * 1LL * (res + 1) / 2;
  if (sum < d) return false;
  return sum % 2 == d % 2;
}
void solve() {
  long long int n, i, j, k, ans, m, o;
  long long int a, b, diff;
  cin >> a >> b;
  if (a > b) swap(a, b);
  diff = b - a;
  long long int cur = 1;
  ans = 0;
  if (diff == 0) {
    cout << 0 << endl;
    return;
  }
  while (!ok(ans, diff)) ans++;
  cout << ans << endl;
  return;
}
int main() {
  fast();
  sample();
  long long int i, j, k, n, m, a, b, c, d, p, q, r, l, t = 1;
  long long int sum, count = 0, ans = 0;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
