#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t, i = 1, ans = 0;
  while (1) {
    ans += i;
    v.push_back(ans);
    if (ans > 1e9) break;
    i++;
  }
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    long long int a1 = max(a, b);
    long long int a2 = min(a, b);
    long long int t1 = a1 - a2;
    if (t1 == 0)
      cout << 0 << "\n";
    else {
      long long int t2 = lower_bound(v.begin(), v.end(), t1) - v.begin();
      if (v[t2] == t1)
        cout << t2 + 1 << "\n";
      else if ((v[t2] - t1) % 2 == 0)
        cout << t2 + 1 << "\n";
      else if (t2 % 2 == 0)
        cout << t2 + 3 << "\n";
      else
        cout << t2 + 2 << "\n";
    }
  }
  return 0;
}
