#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  long long a, b;
  for (int l = 0; l < t; l++) {
    cin >> a >> b;
    if (a == b) {
      cout << 0 << endl;
    } else {
      long long diff = abs(a - b);
      long long index = 0;
      while (true) {
        if (((index + 1) * index >= 2 * diff) &&
            (((index + 1) * index / 2 - diff) % 2 != 1)) {
          cout << index << endl;
          break;
        }
        index++;
      }
    }
  }
  return 0;
}
