#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int MAXN = 0x7fffffff;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
void file() {}
signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int l = 0, r = 1e7;
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << "\n";
      continue;
    }
    a = abs(a - b);
    int num = a * 2;
    num = sqrt(num);
    num = max(num - 10, 1);
    for (int i = num;; i++) {
      long long temp = i * (i + 1) / 2;
      long long aa = temp + a;
      if (aa % 2 == 0 && temp >= a) {
        cout << i << "\n";
        break;
      }
    }
  }
  return 0;
}
