#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a > b) return a;     return b;   }   long long min(long long a, long long b) {     if (a > b) return b;     return a;   }   int main() {     {       ios_base::sync_with_stdio(false);       cin.tie(NULL);     };     int q;     cin >> q;     while (q--) {       long long a, b, c, r;       cin >> a >> b >> c >> r;       long long ans = 0;       if (b < a) {         long long temp = b;         b = a;         a = temp;       }       long long low = c - r;       long long high = c + r;       if (a <= low && high <= b) {         ans = b - a - (high - low);       } else if (low <= a && high <= b && a <= high) {         ans = b - a - (high - a);       } else if (b <= high && a <= low && low <= b) {         ans = b - a - (b - low);       } else if (low <= a && b <= high) {         ans = 0;       } else {         ans = b - a;       }       cout << ans <<   n ;     }     return 0;   }   