#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
void solve() {
  long long a, b, n = (long long)1e5 + 10, ans = 0;
  cin >> a >> b;
  long long sum[n], k = max(b, a) - min(b, a);
  sum[0] = 0;
  for (long long i = 1; i < n; i++) sum[i] = sum[i - 1] + i;
  for (long long i = 0; i < n; i++) {
    if (sum[i] >= k and (!((sum[i] - k) & 1))) {
      ans = i;
      break;
    }
  }
  cout << ans << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
