#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int diff, a, b, start, s = 0, p = 0;
    cin >> a >> b;
    diff = abs(a - b);
    if (diff == 0)
      cout << 0 << endl;
    else {
      for (start = 1; diff > p; start++) {
        s = (start * (start + 1) / 2);
        if ((s + diff) % 2 != 0) continue;
        p = (s + diff) / 2;
        if (p - diff >= 0) break;
      }
      cout << start << endl;
    }
  }
  return 0;
}
