#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    int d = abs(a - b);
    if (d == 0) {
      cout << 0 << endl;
      continue;
    }
    int e = 0;
    for (int i = 0; (i * (i + 1)) / 2 < d; i++) {
      e = i;
    }
    e++;
    if ((e * (e + 1)) / 2 == d) {
      cout << e << endl;
      continue;
    }
    if (d % 2) {
      if (e % 4 == 3)
        e += 2;
      else if (e % 4 == 0)
        e++;
    } else {
      if (e % 4 == 1)
        e += 2;
      else if (e % 4 == 2)
        e++;
    }
    cout << e << endl;
  }
}
