#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    int cou = 0;
    while (cou + 1 <= b - a) {
      a += cou + 1;
      cou++;
    }
    if (b != a) {
      if ((b - a + cou + 1) % 2 == 0)
        cou += 1;
      else if ((b - a) % 2 == 1 && (cou + 1) % 2 == 0)
        cou += 2;
      else
        cou += 3;
    }
    printf("%d\n", cou);
  }
}
