#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, a, b, diff, n;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    diff = abs(a - b);
    n = ceil((-1 + sqrt(1 + 8 * diff)) / 2);
    if (((n + 1) / 2) % 2 != diff % 2) {
      if (n % 2)
        n += 2;
      else
        n++;
    }
    if (n == -0) n = 0;
    cout << n << '\n';
  }
}
