#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  long long int a, b, c;
  while (t--) {
    cin >> a;
    cin >> b;
    c = (a < b) ? (b - a) : (a - b);
    if (c == 0) {
      cout << 0 << endl;
      continue;
    } else if ((c == 1)) {
      cout << 1 << endl;
      continue;
    } else {
      long long int n = 0;
      long long int d = 0;
      do {
        n++;
        while (d < c) {
          n++;
          d = n * (n + 1) / 2;
        }
        d = n * (n + 1) / 2;
      } while ((d - c) % 2);
      cout << n << endl;
    }
  }
  return 0;
}
