#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
void init() {
  iostream::sync_with_stdio(false);
  cout << fixed << setprecision(20);
}
void solve() {
  long long a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  if (a == b) {
    cout << 0 << endl;
    return;
  }
  for (long long q = 1;; ++q) {
    a += q;
    if (a >= b && (a - b) % 2 == 0) {
      cout << q << endl;
      return;
    }
  }
  return;
}
int main() {
  init();
  int test_case;
  cin >> test_case;
  for (long long i = 0; i < test_case; ++i) {
    solve();
  }
}
