#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template <class T, class U>
void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template <class T>
void init_n(vector<T>& v, size_t n) {
  init_n(v, n, T());
}
template <class T>
void read_n(vector<T>& v, size_t n, size_t o = 0) {
  v = vector<T>(n + o);
  for (size_t i = o; i < n + o; ++i) cin >> v[i];
}
template <class T>
void read_n(T a[], size_t n, size_t o = 0) {
  for (size_t i = o; i < n + o; ++i) cin >> a[i];
}
template <class T>
T gabs(const T& x) {
  return max(x, -x);
}
i64 solve() {
  i64 a, b;
  cin >> a >> b;
  i64 d = gabs(a - b);
  if (d == 0) {
    return 0;
  }
  for (i64 i = 1;; i++) {
    i64 x = i * (i + 1) / 2;
    if (x == d) {
      return i;
    }
    if (x > d && x % 2 == d % 2) {
      return i;
    }
  }
}
int main() {
  int n;
  cin >> n;
  while (n--) {
    cout << solve() << '\n';
  }
  return 0;
}
