#include <bits/stdc++.h> using namespace std; typedef long long LL; int main() { int T; cin >> T; while(T--) { LL a, b; cin >> a >> b; LL k = abs(a - b); LL l = -1, r = 1e5; while(l + 1 < r) { LL mid = l + r >> 1; if(mid*(mid+1)/2 <= k) { l = mid; } else { r = mid; } } while(l*(l+1)/2 < k || (l*(l+1)/2-k)&1) ++l; cout << l << endl; } return 0; }