#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b;
  cin >> a >> b;
  ;
  long long c, r;
  cin >> c >> r;
  ;
  long long Xnet = c - r;
  long long Ynet = c + r;
  long long start = max(Xnet, min(a, b));
  long long end = min(Ynet, max(a, b));
  long long zero = 0;
  cout << abs(a - b) - max(zero, (end - start)) << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) solve();
  return 0;
}
