#include <bits/stdc++.h>
using namespace std;
void solve() {
  int a, b;
  cin >> a >> b;
  ;
  int c, r;
  cin >> c >> r;
  ;
  int start = max(c - r, min(a, b));
  int end = min(c + r, max(a, b));
  cout << abs(a - b) - max(0, (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;
}
