#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  int t;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    long long d = abs(a - b);
    if (!d) {
      cout << "0\n";
      continue;
    }
    int cnt = 1;
    while (1) {
      long long sum = cnt * (cnt + 1) / 2;
      if (sum >= d) {
        if ((sum % 2) == (d % 2)) break;
      }
      cnt++;
    }
    cout << cnt << endl;
  }
}
