#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, f, cycle, st, fin, kol;
vector<vector<long long> > arr1, arr, parent;
vector<pair<long long, long long> > ar1, ar;
vector<vector<long long> > dp;
void solve() {
  long long a, b, c, r;
  cin >> a >> b >> c >> r;
  if (a > b) swap(a, b);
  long long left = c - r;
  long long right = r + c;
  if (right <= a || left >= b) {
    cout << b - a << endl;
    return;
  }
  if (left <= a) left = a;
  if (right >= b) right = b;
  cout << b - a - (right - left) << endl;
  return;
}
int main() {
  cin >> a;
  for (long long i = 0; i < a; ++i) solve();
}
