#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    int x = 0;
    while (x * (x + 1) / 2 < a - b || x * (x + 1) / 2 % 2 != (a - b) % 2) x++;
    cout << x << endl;
  }
  return 0;
}
