#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, t;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    int dif = abs(a - b);
    int i, sum = 0;
    for (i = 1; sum < dif; i++) sum += i;
    if (sum == dif || (sum - dif) % 2 == 0)
      cout << i - 1 << "\n";
    else {
      while ((sum - dif) % 2) sum += i++;
      cout << i - 1 << "\n";
    }
  }
  return 0;
}
