#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long tc;
  cin >> tc;
  while (tc--) {
    long long n, m;
    cin >> n >> m;
    long long x = abs(n - m);
    if (n == m) {
      cout << 0 << endl;
      continue;
    }
    long long low = 1;
    long long high = 100009;
    long long mid;
    while (high - low > 1) {
      mid = (low + high) / 2;
      long long p = (mid * (mid + 1)) / 2;
      if (p <= x)
        low = mid;
      else
        high = mid;
    }
    long long ans = low;
    if ((ans * (ans + 1)) / 2 < x) {
      ans++;
      while (((ans * (ans + 1)) / 2) % 2 != (x % 2)) {
        ans++;
      }
    }
    cout << ans << endl;
  }
}
