#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    long long a, b, c;
    cin >> a >> b;
    c = abs(a - b);
    long long i = 1;
    if (!c) {
      cout << 0 << "\n";
      continue;
    }
    while (c > 0) {
      c -= i;
      i++;
    }
    if (!c) {
      cout << i - 1 << "\n";
      continue;
    }
    i--;
    if (c % 2 == 0) {
      cout << i << "\n";
    } else {
      i++;
      c -= i;
      if (c % 2 == 0) {
        cout << i << "\n";
      } else {
        cout << i + 1 << "\n";
      }
    }
  }
  return 0;
}
