#include <bits/stdc++.h>
using namespace std;
bool ok(int a, int b, int n) { return 1LL * n * (n + 1) >= 2 * (b - a); }
int solve(int a, int b) {
  if (a > b) swap(a, b);
  int l = 0, r = b;
  int found = -1;
  while (l <= r) {
    int mid = l + (r - l) / 2;
    if (ok(a, b, mid)) {
      found = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  int n = found;
  while ((b - a + 1LL * n * (n + 1) / 2) % 2 != 0) ++n;
  return n;
}
bool bkt_ok(int a, int b, int n) {
  for (int msk = 0, lim = (1 << n); msk < lim; ++msk) {
    int aa = a, bb = b;
    for (int i = 0; i < n; ++i) {
      if (msk & (1 << i))
        aa += i + 1;
      else
        bb += i + 1;
    }
    if (aa == bb) {
      printf("!!! %d\n", msk);
      return true;
    }
  }
  return false;
}
int bkt(int a, int b) {
  int maxops = 20;
  for (int n = 0; n < maxops; ++n) {
    if (bkt_ok(a, b, n)) return n;
  }
  return -1;
}
int main() {
  int T;
  scanf("%d", &T);
  srand(69);
  while (T--) {
    int a, b;
    scanf("%d%d", &a, &b);
    int r1 = solve(a, b);
    printf("%d\n", r1);
  }
  return 0;
}
