#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 0;
  cin >> t;
  while (t > 0) {
    long long int a, b;
    cin >> a >> b;
    long long int sa = 0, ans = 0;
    while (sa < abs(b - a) || abs(sa - abs(b - a)) % 2 != 0) {
      sa += ++ans;
    }
    cout << ans << endl;
    t--;
  }
  return 0;
}
