#include <bits/stdc++.h>
using namespace std;
const long long M = 998244353;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b, c, r;
    cin >> a >> b >> r >> c;
    if (a > b) {
      swap(a, b);
    }
    long long left = r - c;
    long long right = r + c;
    long long k = 0;
    k = max(k, min(right, b) - max(left, a));
    cout << (b - a) - k << '\n';
  }
}
