#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b, c, r;
  cin >> a >> b >> c >> r;
  if (a > b) {
    swap(a, b);
  }
  long long now = (b - a);
  long long L = c - r, R = c + r;
  if (R < a || b < L) {
    cout << now << endl;
    return;
  }
  if (L <= a && b <= R) {
    cout << 0 << endl;
    return;
  }
  a = max(a, L);
  b = min(b, R);
  cout << now - (b - a) << endl;
}
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
