#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, t, m, k, l;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    i = 0;
    l = min(n, m);
    m = max(n, m);
    while (l + (i * (i + 1)) / 2 < m || (l + (i * (i + 1)) / 2 - m) % 2 != 0)
      i++;
    cout << i << endl;
  }
  return 0;
}
