#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T;
  cin >> T;
  while (T--) {
    long long A, B;
    cin >> A >> B;
    long long Ans = 0;
    long long Max = max(A, B);
    long long Min = min(A, B);
    long long Cnt = 1;
    while (1) {
      if (Min < Max) {
        Min += Cnt++;
      } else if (Min == Max)
        break;
      else {
        if ((Min - Max) % 2 == 0)
          break;
        else
          Min += Cnt++;
      }
      Ans++;
    }
    cout << Ans << endl;
  }
  return 0;
}
