#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, R, l = 0, r = 0;
    cin >> a >> b >> c >> R;
    if (a > b) swap(a, b);
    l = c - R;
    r = c + R;
    int x = max(a, l);
    int y = min(b, r);
    int got = max(0, y - x);
    cout << b - a - got << endl;
  }
}
