#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b, c, r;
  cin >> t;
  while (t--) {
    cin >> a >> b >> c >> r;
    if (a > b) {
      swap(a, b);
    }
    int distancia = b - a;
    int istation = c - r;
    int fstation = c + r;
    if (istation >= b || fstation <= a) {
      cout << distancia << endl;
    } else if (istation <= a && fstation >= b) {
      cout << 0 << endl;
    } else if (istation >= a && fstation <= b) {
      cout << distancia - (fstation - istation) << endl;
    } else if (istation >= a && fstation >= b) {
      cout << distancia - (b - istation) << endl;
    } else if (istation <= a && fstation <= b) {
      cout << distancia - (fstation - a) << endl;
    }
  }
  return 0;
}
