#include <bits/stdc++.h>
using namespace std;
int n, a, b;
const int maxn = 1e9 + 12;
void Speed() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  Speed();
  cin >> n;
  while (n--) {
    cin >> a >> b;
    int mx = max(a, b);
    if (a == b) {
      cout << "0\n";
      continue;
    }
    int ans = -1;
    for (int i = 1; i <= maxn; i++) {
      int y = (i * (i + 1)) / 2;
      if (a + b + y >= mx * 2 && (a + b + y) % 2 == 0) {
        ans = i;
        break;
      }
    }
    if (ans == -1) {
      cout << "0\n";
    } else {
      cout << ans << "\n";
    }
  }
}
