#include <bits/stdc++.h>
using namespace std;
signed main() {
  std ::ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long a, b, i;
    cin >> a >> b;
    a = abs(a - b);
    if (a == 0) {
      cout << 0 << "\n";
      continue;
    }
    for (i = 1;; i++) {
      long long sum = i * (i + 1) / 2;
      if (sum % 2 != a % 2 || a > sum) continue;
      break;
    }
    cout << i << "\n";
  }
}
