#include <bits/stdc++.h>
using namespace std;
int t, m, n, i, j, flag, a, b, c, ans, ans1, k;
int main() {
  cin >> t;
  getchar();
  while (t--) {
    scanf("%d", &a);
    scanf("%d", &b);
    if (a < b) {
      c = a;
      a = b;
      b = c;
    }
    i = 1;
    while (a > b) {
      b = b + i;
      i = i + 1;
    }
    while (b > a && (b - a) % 2 == 1) {
      b = b + i;
      i = i + 1;
    }
    ans = i - 1;
    cout << ans << "\n";
  }
}
