#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    int a, b, c, r;
    cin >> a >> b >> c >> r;
    int x = c - r;
    int y = c + r;
    if (a > b) {
      swap(a, b);
    }
    int intersection = max(min(b, y) - max(a, x), 0);
    cout << b - a - intersection << endl;
  }
  return 0;
}
