#include <bits/stdc++.h>
using namespace std;
inline char nc() {
  static char buf[1000000], *p1, *p2;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <typename T>
inline int scan(T &x) {
  char c, sign = 1;
  while (!isdigit(c = nc()) && c != EOF)
    if (c == '-') sign *= -1;
  if (c == EOF) return EOF;
  for (x = 0; isdigit(c); c = nc()) x = (x << 1) + (x << 3) + (c & 15);
  return x *= sign, 1;
}
template <typename T, typename... Args>
inline int scan(T &x, Args &...args) {
  return scan(x), scan(args...);
}
int main() {
  int QAQ;
  for (cin >> QAQ; QAQ; QAQ--) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    int t = b - a;
    int ans = 0, L = 0, R = 45000, mid;
    while (L <= R) {
      mid = (L + R) >> 1;
      if (1LL * mid * (mid + 1) / 2 >= t)
        ans = mid, R = mid - 1;
      else
        L = mid + 1;
    }
    int tp = ans * (ans + 1) / 2 - t;
    while (tp & 1) ++ans, tp = ans * (ans + 1) / 2 - t;
    cout << ans << endl;
  }
}
