#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  for (long long int ij = 0; ij < n; ++ij) {
    long long int a, b;
    cin >> a >> b;
    long long int p = llabs(a - b), s = 0, i = 0, d = 0;
    while (s < p || d == 0) {
      ++i;
      s += i;
      if (s >= p) {
        if (s % 2 == p % 2) {
          ++d;
        }
      }
    }
    if (a == b)
      cout << 0 << endl;
    else
      cout << i << endl;
  }
}
