#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b;
  cin >> a >> b;
  if (a < b) swap(a, b);
  if (a == b) {
    cout << "0" << endl;
    return;
  }
  int ans = 1;
  while (1) {
    int sum = ans * (ans + 1) / 2;
    if (sum >= a - b && (a - b) % 2 == sum % 2) break;
    ans++;
  }
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
