#include <bits/stdc++.h>
using namespace std;
long long T, a, b, ans, delta;
int main() {
  cin >> T;
  while (T--) {
    ans = 0;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    delta = (a > b) ? a - b : b - a;
    long long ll, rr, mid;
    ll = 1, rr = 100000, mid = 0;
    while (ll < rr) {
      if (ll == rr - 1)
        mid = ll;
      else
        mid = (ll + rr + 1) >> 1;
      if (mid * (mid + 1) / 2 < delta)
        ll = mid + 1;
      else
        rr = mid;
    }
    ans = ll;
    if (((ans + 1) * ans / 2 + delta) % 2) {
      while (((ans + 1) * ans / 2 + delta) % 2) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
