#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e6 + 4;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int a, b, c, r;
    cin >> a >> b >> c >> r;
    int x = c - r, y = c + r;
    if (a > b) swap(a, b);
    int val = 0;
    if (x < a) {
      if (y > a) val = min(b, y) - a;
    } else if (x < b) {
      val = min(y, b) - x;
    }
    printf("%d\n", b - a - val);
  }
  return 0;
}
