#include <bits/stdc++.h>
using namespace std;
int a, b, s, cnt, t;
int main() {
  cin >> t;
  while (t--) {
    cnt = 0;
    cin >> a >> b;
    int c = abs(a - b);
    int x = 1;
    if (c == 0) {
      cout << 0 << endl;
      continue;
    }
    while (cnt += x) {
      if (c <= cnt && (cnt - c) % 2 == 0) {
        cout << x << endl;
        break;
      }
      x++;
    }
  }
  return 0;
}
