#include <bits/stdc++.h>
using namespace std;
void solve() {
  int a, b, c, r;
  cin >> a >> b >> c >> r;
  if (a > b) swap(a, b);
  int l = c - r, ri = c + r;
  int res = 0;
  if (l <= b) {
    if (ri < a) {
      cout << b - a << "\n";
    } else {
      int res = b - a;
      res -= abs(min(ri, b) - max(l, a));
      cout << res << "\n";
    }
  } else
    cout << b - a << "\n";
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
