#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int n, long long int m) {
  long long int res = 1;
  while (n) {
    if (n & 1) {
      res = ((res) * (a));
      n--;
    } else {
      a = ((a) * (a));
      n /= 2;
    }
  }
  return res;
}
void solve(long long int t) {
  long long int a, b;
  cin >> a >> b;
  long long int i = 1;
  if (a == b) {
    cout << 0 << "\n";
    return;
  }
  long long int dif = abs(a - b);
  while (1) {
    long long int res1 = i * (i + 1) / 2;
    if (res1 >= dif and res1 % 2 == dif % 2) break;
    i++;
  }
  cout << i << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  cin >> t;
  long long int flag = 1;
  while (t--) {
    solve(flag);
    flag++;
  }
}
