#include <bits/stdc++.h>
using namespace std;
long long mod_exp(long long x, long long y, long long mm) {
  if (y == 0)
    return (1);
  else if (y % 2 == 0)
    return (mod_exp((x * x) % mm, y / 2, mm));
  else
    return ((x * mod_exp((x * x) % mm, (y - 1) / 2, mm)) % mm);
}
bool isPowerOfTwo(int n) {
  if (n == 0) return false;
  return (ceil(log2(n)) == floor(log2(n)));
}
int solve() {
  int a, b;
  cin >> a >> b;
  if (a == b) return 0;
  int diff = abs(a - b);
  int y = min(a, b);
  int z = max(a, b);
  int cnt = 1;
  int ans = 0;
  while (1) {
    ++ans;
    y += cnt;
    if (y == z) return ans;
    if (y > z && (y - z) % 2 == 0) {
      return ans;
    }
    ++cnt;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) cout << solve() << "\n";
  return 0;
}
