#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, r;
    scanf("%d%d%d%d", &a, &b, &c, &r);
    if (a > b) swap(a, b);
    int l = max(a, c - r), rr = min(b, c + r);
    int ans = max(0, rr - l);
    ans = b - a - ans;
    printf("%d\n", ans);
  }
  return 0;
}
