#include <bits/stdc++.h>
using namespace std;
signed main() {
  std ::ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  long long a, b;
  while (t--) {
    cin >> a >> b;
    long long diff = abs(a - b);
    if (!diff) {
      cout << 0 << '\n';
      continue;
    }
    long long sum = 0;
    long long i = 1;
    for (; (diff > sum) || (diff + sum) % 2; i++) sum += i;
    i--;
    cout << i << '\n';
  }
}
