#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, r;
    cin >> a >> b >> c >> r;
    if (a > b) swap(a, b);
    int ans = b - a;
    if (ans == 0)
      puts("0");
    else {
      int x = c - r;
      int y = c + r;
      if (y < a || x > b)
        cout << ans << "\n";
      else {
        int x = min(c + r, b);
        int y = max(a, c - r);
        ans -= x - y;
        cout << ans << "\n";
      }
    }
  }
}
