#include <bits/stdc++.h>
using namespace std;
long long t, a, b, d;
bool fun(long long mid) {
  long long total = mid * (mid + 1) / 2;
  if (total >= d) {
    return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> a >> b;
    d = abs(a - b);
    long long s = 0, e = 1000000007, mid;
    while (s < e) {
      mid = (s + e) / 2;
      if (fun(mid)) {
        e = mid;
      } else {
        s = mid + 1;
      }
    }
    long long total = s * (s + 1) / 2;
    while (total % 2 != d % 2) {
      s++;
      total = s * (s + 1) / 2;
    }
    cout << s << endl;
  }
  return 0;
}
