#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long MAX = 100005;
const long double PI = 3.14159265359;
const long double G = 9.807;
const long long INF = 1e18;
const long double EPS = 1e-6;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
bool isprime(long long a) {
  if (a == 2) return 1;
  if (!(a & 1)) return 0;
  for (long long i = 3; i * i <= a; i += 2)
    if (a % i == 0) return 0;
  return 1;
}
long long mpow(long long base, long long exponent, long long modulus) {
  if (modulus == 1) return 0;
  long long result = 1;
  base = base % modulus;
  while (exponent) {
    if (exponent % 2 == 1) result = (result * base) % modulus;
    exponent = exponent >> 1;
    base = (base * base) % modulus;
  }
  return result;
}
long long minv(long long a, long long mod) {
  long long _gcd = gcd(a, mod);
  assert(_gcd == 1);
  return mpow(a, mod - 2, mod);
}
long long t;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << '\n';
      continue;
    }
    long long X = a + b;
    long long mx = max(a, b);
    if (X & 1) {
      long long lo = 0, hi = 100000000;
      while (lo < hi) {
        long long mid = (lo + hi) >> 1;
        long long num1 = 4 * mid + 1;
        long long num2 = 4 * mid + 2;
        long long ad1 = (X + num1 * (num1 + 1) / 2) / 2;
        long long ad2 = (X + num2 * (num2 + 1) / 2) / 2;
        if (ad1 >= mx or ad2 >= mx) {
          hi = mid;
        } else {
          lo = mid + 1;
        }
      }
      long long ans1 = 4 * lo + 1;
      long long ans2 = 4 * lo + 2;
      long long ad1 = (X + ans1 * (ans1 + 1) / 2) / 2;
      long long ad2 = (X + ans2 * (ans2 + 1) / 2) / 2;
      if (ad1 >= mx) {
        cout << ans1 << '\n';
      } else {
        cout << ans2 << '\n';
      }
    } else {
      long long lo = 0, hi = 100000000;
      while (lo < hi) {
        long long mid = (lo + hi) >> 1;
        long long num1 = 4 * mid;
        long long num2 = 4 * mid + 3;
        long long ad1 = (X + num1 * (num1 + 1) / 2) / 2;
        long long ad2 = (X + num2 * (num2 + 1) / 2) / 2;
        if (ad1 >= mx or ad2 >= mx) {
          hi = mid;
        } else {
          lo = mid + 1;
        }
      }
      long long ans1 = 4 * lo;
      long long ans2 = 4 * lo + 3;
      long long ad1 = (X + ans1 * (ans1 + 1) / 2) / 2;
      long long ad2 = (X + ans2 * (ans2 + 1) / 2) / 2;
      if (ad1 >= mx) {
        cout << ans1 << '\n';
      } else {
        cout << ans2 << '\n';
      }
    }
  }
  return 0;
}
