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