#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t-- > 0) {
    int a, b, c, r;
    cin >> a >> b >> c >> r;
    if (a > b) swap(a, b);
    if (c - r > b || a > c + r) {
      cout << b - a << "\n";
    } else {
      cout << (b - a - (min(b, c + r) - max(a, c - r))) << "\n";
    }
  }
}
