#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int test = 1;
  cin >> test;
  while (test--) {
    long long int a, b;
    cin >> a >> b;
    long long int temp = a;
    a = ((a > b) ? b : a);
    b = ((b > temp) ? b : temp);
    long long int diff = b - a;
    long long int i;
    for (i = 0;; i++) {
      temp = (i * (i + 1)) / 2;
      if (diff <= temp && temp % 2 == diff % 2) {
        break;
      }
    }
    cout << i << "\n";
  }
  return 0;
}
