#include <bits/stdc++.h>
using namespace std;
int main() {
  long long arr[45001];
  for (long long i = 1; i < 45000 + 1; i++) arr[i] = (i * (i + 1)) / 2;
  long long T;
  cin >> T;
  while (T--) {
    long long a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    long long K = b - a, ans;
    if (K > 0) K = K * (-1);
    for (long long i = 1; i <= 45000; i++) {
      if ((K + arr[i]) >= 0 && (K + arr[i]) % 2 == 0) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  }
}
