#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
const int mod = 998244353;
const long long INF = 1e18;
const double PI = 3.1415926535897932384626433;
const long double EPS = 1e-12;
inline long long bpow(long long a, long long b, long long mod = 1e9 + 7) {
  long long res = a, ret = 1;
  while (b > 0) {
    if (b % 2) ret = (ret * res) % mod;
    res = (res * res) % mod;
    b /= 2;
  }
  return ret;
}
long long t, a, b;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> a >> b;
    long long cnt = 0, d = 1;
    if (a > b) {
      swap(a, b);
    }
    cnt = d = ceil((-1 + sqrt(1 + (b - a) * 8)) / 2);
    if ((a + b + d * (d + 1) / 2) & 1) {
      if (d & 1)
        cnt += 2;
      else
        cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}
