#include <bits/stdc++.h>
using namespace std;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
double pi = 3.1415926536;
int MOD = 1e9 + 7;
long long power(long long x, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x;
    x = (x * x);
    n /= 2;
  }
  return res;
}
bool ok(int n, long long d) {
  long long sum = (n * (n + 1) / 2);
  if (sum < d) return false;
  return (d % 2 == sum % 2);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    int i = 0;
    while (!ok(i, abs(a - b))) i++;
    cout << i << '\n';
  }
}
