#include <bits/stdc++.h>
using namespace std;
long long POW(long long x, long long y) {
  long long temp = 1;
  for (long long i = 0; i < y; i++) {
    temp *= x;
  }
  return temp;
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    long long sum = 0;
    long long diff = abs(a - b);
    for (long long i = 1;; i++) {
      sum += i;
      if ((sum + a + b) % 2 == 0 && sum >= diff) {
        cout << i << endl;
        break;
      }
    }
  }
}
