#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t-- > 0) {
    long long int a, b;
    cin >> a >> b;
    long long int k = 1, d = -abs(a - b);
    while (d < 0) {
      d += k;
      k++;
    }
    if (d % 2 == 0) {
      cout << k - 1 << "\n";
    } else {
      d += k;
      if (d % 2 == 0) {
        cout << k << "\n";
      } else {
        cout << k + 1 << "\n";
      }
    }
  }
  return 0;
}
