#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
void solve() {
  int a, b, c, r;
  scanf("%d %d %d %d", &a, &b, &c, &r);
  if (a > b) {
    int t = a;
    a = b;
    b = t;
  }
  int l = max(a, c - r);
  int h = min(b, c + r);
  int d = 0;
  if (l < h) d = h - l;
  printf("%d\n", b - a - d);
}
int main() {
  int test;
  scanf("%d", &test);
  while (test--) solve();
}
