#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  long long int i, j, a, b, ans;
  for (i = 1; i <= t; i++) {
    cin >> a >> b;
    ans = 0;
    while ((a + b + ans * (ans + 1) / 2) % 2 != 0 ||
           (a + b + ans * (ans + 1) / 2) < 2 * max(a, b)) {
      ans++;
    }
    cout << ans << endl;
  }
}
