#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  std::vector<long long> v;
  v.clear();
  for (long long i = 1; i < 1000000; ++i) {
    long long x = i * (i + 1);
    x /= 2;
    v.push_back(x);
  }
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long temp = abs(a - b);
    if (a - b == 0) {
      cout << 0 << endl;
      continue;
    }
    std::vector<long long>::iterator upper;
    upper = std::lower_bound(v.begin(), v.end(), temp);
    long long pos = (upper - v.begin());
    while ((v[pos] + a + b) % 2 != 0) {
      pos++;
    }
    cout << pos + 1 << endl;
  }
}
