#include <bits/stdc++.h>
using namespace std;
vector<long long> v(100001);
void check() {
  v[0] = 0, v[1] = 1;
  for (int i = 2; i < 100001; i++) {
    v[i] = v[i - 1] + i;
  }
}
int main() {
  check();
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long diff = abs(b - a);
    long long g = diff;
    while (1) {
      auto it = lower_bound(v.begin(), v.end(), diff);
      if ((*it - g) % 2 == 0) {
        cout << it - v.begin() << endl;
        break;
      } else {
        diff += *it - diff + 1;
      }
    }
  }
  return 0;
}
