#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int t;
  cin >> t;
  for (int ii = 0; ii < t; ++ii) {
    long long int a, b;
    cin >> a >> b;
    int diff = abs(a - b);
    if (a > b) {
      swap(a, b);
    }
    int h = 0, ans = 0;
    while (a < b || (a - b) % 2) {
      h++;
      a = a + h;
      ans++;
    }
    cout << h << "\n";
  }
  return 0;
}
