#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long diff = abs(a - b);
    long long val = 0;
    long long sum = 0;
    while (sum < diff) {
      sum = val * (val + 1) / 2;
      val++;
    }
    if (val != 0) val--;
    long long flag = diff % 2;
    if (sum % 2 == flag) {
      cout << val << endl;
    } else {
      long long value1 = val + 1;
      long long sum1 = value1 * (value1 + 1) / 2;
      if (sum1 % 2 == flag) {
        cout << value1 << endl;
      } else {
        long long value2 = val + 2;
        cout << value2 << endl;
      }
    }
  }
}
