#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  int t, a, b;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a < b) swap(a, b);
    a -= b;
    for (int i = 0;; i++) {
      int cur = 1LL * i * (i + 1) / 2;
      if (cur >= a && cur % 2 == a % 2) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}
