#include <bits/stdc++.h>
using namespace std;
long long T, a, b, ans;
int main() {
  scanf("%lld", &T);
  while (T--) {
    scanf("%lld%lld", &a, &b);
    ans = 0;
    while (!((a + b + ans * (ans + 1) / 2) % 2 == 0 &&
             a + b + ans * (ans + 1) / 2 >= 2 * max(a, b)))
      ans++;
    printf("%lld\n", ans);
  }
  return 0;
}
