#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
int main() {
  int t;
  cin >> t;
  for (int _ = 0; _ < t; _++) {
    int a, b;
    cin >> a >> b;
    int d = max(a, b) - min(a, b);
    int id = 0, sum = 0;
    while (sum < d || (d % 2 != sum % 2)) {
      sum += id;
      id++;
    }
    int ans = id;
    if (ans) ans--;
    cout << ans << endl;
  }
}
