#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int cases;
  cin >> cases;
  for (int i = 0; i < cases; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    int dis = b - a;
    if (dis == 0)
      cout << 0 << "\n";
    else if (dis == 1)
      cout << 1 << "\n";
    else {
      long long int ans = 1;
      while (true) {
        long long int sum = (ans * (ans + 1)) / 2;
        if (sum >= dis) {
          if (sum % 2 == dis % 2) break;
        }
        ans++;
      }
      cout << ans << "\n";
    }
  }
  return 0;
}
