#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int a, b, i, j;
  cin >> a >> b;
  long long int d = b - a;
  if (d < 0) d = -d;
  if (d == 0)
    cout << "0\n";
  else {
    j = 0;
    for (i = 1;; i++) {
      j += i;
      if (j % 2 == d % 2 && j >= d) {
        cout << i << '\n';
        return;
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) solve();
  cerr << "\nTime elapsed: " << setprecision(5)
       << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
