#include <bits/stdc++.h>
using namespace std;
long long n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  while (n--) {
    int a, b;
    cin >> a >> b;
    int diff = abs(a - b);
    if (diff == 0) {
      cout << 0 << '\n';
      continue;
    }
    long long mini = 0, maxi = diff;
    while (mini + 1 < maxi) {
      long long middle = (mini + maxi) / 2;
      if (((middle + 1) * middle) / 2 <= diff)
        mini = middle;
      else
        maxi = middle;
    }
    if (diff == ((mini + 1) * mini) / 2) {
      cout << mini << '\n';
      continue;
    }
    int other = ((mini + 1) * mini) / 2;
    other += mini + 1;
    if ((other - diff) % 2 == 0) {
      cout << mini + 1 << '\n';
      continue;
    }
    other += mini + 2;
    if ((other - diff) % 2 == 0) {
      cout << mini + 2 << '\n';
      continue;
    }
    cout << mini + 3 << '\n';
  }
}
