#include <bits/stdc++.h>
using namespace std;
long long val[100000];
void pre() {
  val[0] = 0;
  for (long long i = 1; i < 100000; i++) val[i] = val[i - 1] + i;
}
long long finnd(long long low, long long high, long long temp) {
  while (low <= high) {
    long long mid = (low + high) / 2;
    if (val[mid] == temp)
      return mid;
    else if (val[mid] > temp)
      high = mid - 1;
    else
      low = mid + 1;
  }
}
int main() {
  pre();
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long d = abs(a - b);
    if (binary_search(val, val + 100000, d)) {
      cout << finnd(0, 100000, d) << "\n";
      continue;
    }
    if (d % 2 == 0) {
      for (long long i = 2; i < 100000; i++) {
        long long temp = d;
        if (val[i] % 2 == 0) temp += val[i];
        if (temp >= 2 * d) {
          cout << i << "\n";
          break;
        }
      }
    } else {
      for (long long i = 1; i < 100000; i++) {
        long long temp = d;
        if (val[i] % 2 == 1) temp += val[i];
        if (temp >= 2 * d) {
          cout << i << "\n";
          break;
        }
      }
    }
  }
}
