#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll d[100005];
void solve() {
  ll a, b;
  scanf("%lld%lld", &a, &b);
  if (a > b) swap(a, b);
  ll c = b - a;
  for (int i = 0; i < 50000; i++) {
    ll k = d[i] - c;
    if (k < 0) continue;
    if (k % 2 == 0)
      printf("%d\n", i);
    else if (i % 2 == 0)
      printf("%d\n", i + 1);
    else
      printf("%d\n", i + 2);
    break;
  }
}
int main() {
  d[0] = 0;
  for (ll i = 1; i < 50000; i++) {
    d[i] = d[i - 1] + i;
  }
  int t;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
