#include <bits/stdc++.h>
using namespace std;
long long sum[100005];
void init() {
  sum[0] = 0;
  for (int i = 1; i < 100005; i++) sum[i] = sum[i - 1] + i;
}
int main() {
  init();
  long long n;
  cin >> n;
  while (n--) {
    long long a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    long long temp = a - b;
    if (temp == 0) {
      cout << "0" << endl;
      continue;
    }
    long long ans = 0;
    long long pos = 0;
    for (int i = 1; i < 100005; i++) {
      if (sum[i] >= temp) {
        ans = sum[i];
        pos = i;
        break;
      }
    }
    if (ans == temp)
      cout << pos << endl;
    else {
      long long now = ans - temp;
      if (now % 2 == 0)
        cout << pos << endl;
      else {
        if ((pos + 1) % 2 == 0)
          cout << pos + 2 << endl;
        else
          cout << pos + 1 << endl;
      }
    }
  }
}
