#include <bits/stdc++.h>
using namespace std;
long long t, a, b, c, i, sum;
int main() {
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld%lld", &a, &b);
    c = abs(a - b);
    i = sum = 0;
    while (!(sum >= c && (sum - c) % 2 == 0)) sum += ++i;
    printf("%lld\n", i);
  }
  return 0;
}
