#include <bits/stdc++.h>
using namespace std;
long long ss[5000000];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t, n, xx, y, cc, f, z;
  cin >> t;
  long long sum = 0, x;
  ss[0] = 0;
  for (x = 1;; x++) {
    sum += x;
    ss[x] = sum;
    if (sum >= 10000000020) break;
  }
  while (t--) {
    long long a, b, diff, p;
    cin >> a >> b;
    diff = abs(a - b);
    for (int i = 0;; i++) {
      if (ss[i] >= diff && diff % 2 == ss[i] % 2) {
        p = i;
        break;
      }
    }
    cout << p << endl;
  }
  return 0;
}
