#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long x, y;
    cin >> x >> y;
    long long a = max(x, y) - min(x, y);
    long long L = 0, R = 1000000007 - 7, m;
    long long ans = INT_MAX;
    for (long long i = max(x, y); i <= max(x, y) + (long long)1e5; i++) {
      long long rem = 2 * i - x - y;
      long long d = (-1 + (long long)sqrt(1 + 8 * rem)) / 2;
      if (d * (d + 1) == 2 * rem) {
        ans = min(ans, d);
        break;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
