#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b;
  int i = 1;
  long long sum = 0;
  cin >> t;
  while (t--) {
    i = 1;
    cin >> a >> b;
    if (b > a) {
      swap(a, b);
    }
    if (a == b) {
      cout << "0" << endl;
      continue;
    }
    while (1) {
      sum = i * (i + 1) / 2;
      if (sum >= (a - b) && sum % 2 == (a - b) % 2) {
        break;
      }
      i++;
    }
    cout << i << endl;
  }
  return 0;
}
