#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1);
const long long MOD = 1e9 + 7;
const int INF = 0x7FFFFFFF;
const long long LINF = 0x7FFFFFFFFFFFFFFFLL;
const unsigned long long UINF = 0xFFFFFFFFFFFFFFFFLL;
const int dCol[] = {0, +1, 0, -1, +1, +1, -1, -1};
const int dRow[] = {-1, 0, +1, 0, -1, +1, +1, -1};
template <typename T>
inline void VIN(vector<T> &i) {
  T x;
  cin >> x;
  i.push_back(x);
}
inline void FIO(string i) {
  freopen((i + ".in").c_str(), "r", stdin);
  freopen((i + ".out").c_str(), "w", stdout);
}
int T;
long long A, B;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> T;
  for (int t = (0); t < (T); t++) {
    cin >> A >> B;
    long long diff = abs(A - B);
    if (diff == 0)
      cout << 0 << "\n";
    else {
      long long ans = 0;
      for (int j = (1); j < (90000); j++) {
        long long sum = j * (j + 1) / 2;
        if (sum < diff) continue;
        if ((sum - diff) % 2 == 0) {
          ans = j;
          break;
        }
      }
      cout << ans << "\n";
    }
  }
  return 0;
}
