#include <bits/stdc++.h>
int main() {
  int t;
  long long int a, b, n, p, i, j, k, rem, diff, val1, val2;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld%lld", &a, &b);
    if (a < b) {
      long long int temp = a;
      a = b;
      b = temp;
    }
    if (a == b)
      printf("%d\n", 0);
    else if (a - b == 1)
      printf("%d\n", 1);
    else {
      diff = a - b;
      int flag = 0;
      i = 4;
      while (flag != 1) {
        flag = 0;
        j = i - 1;
        k = i + 1;
        val1 = (j * j - 1) - (8 * diff);
        val2 = (k * k - 1) - (8 * diff);
        if (val1 >= 0) {
          rem = val1 % 16;
          if (rem == 0) {
            printf("%lld\n", (j - 1) / 2);
            flag = 1;
          }
        }
        if (flag == 1) break;
        if (val2 >= 0) {
          rem = val2 % 16;
          if (rem == 0) {
            printf("%lld\n", (k - 1) / 2);
            flag = 1;
          }
        }
        if (flag == 1) break;
        i += 4;
      }
    }
  }
  return 0;
}
