#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, r;
    cin >> a >> b >> c >> r;
    if (a > b) swap(a, b);
    int d = c - r, e = c + r;
    if (d <= a) {
      if (e < a)
        cout << b - a << '\n';
      else if (e < b)
        cout << b - e << '\n';
      else
        cout << 0 << '\n';
    } else if (d < b) {
      if (e < b)
        cout << b - a - e + d << '\n';
      else
        cout << d - a << '\n';
    } else
      cout << b - a << '\n';
  }
  return 0;
}
