#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t != 0) {
    long long int a, b, i = 1, operations = 0;
    cin >> a >> b;
    long long int dif = abs(a - b);
    if (dif == 0)
      operations = -1;
    else {
      for (i;; ++i) {
        long long int sum = i * (i + 1) / 2;
        if (sum >= dif && sum % 2 == dif % 2)
          break;
        else
          operations++;
      }
    }
    cout << operations + 1 << endl;
    t--;
  }
}
