#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int main() {
  for (int i = 0; i <= 100005; i++) {
    long long x = (i * (i + 1)) / 2;
    v.push_back(x);
  }
  int tc;
  cin >> tc;
  while (tc--) {
    long long a, b, d, res = 0;
    cin >> a >> b;
    if (a > b) swap(a, b);
    d = b - a;
    for (auto x : v) {
      long long p = x + d;
      if ((p % 2) == 0) {
        p /= 2;
        if (((a + p) == (b + (x - p))) && (x >= p)) break;
      }
      res++;
    }
    cout << res << endl;
  }
  return 0;
}
