#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b, c, r, dmin, dmax;
  cin >> t;
  int arr[t][4];
  for (int i = 0; i < t; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> arr[i][j];
    }
  }
  for (int i = 0; i < t; i++) {
    cin >> a >> b >> c >> r;
    int temp = arr[i][0];
    arr[i][0] = min(arr[i][0], arr[i][1]);
    arr[i][1] = max(temp, arr[i][1]);
    dmin = arr[i][2] - arr[i][3];
    dmax = arr[i][2] + arr[i][3];
    if (dmax < arr[i][0]) {
      cout << (arr[i][1] - arr[i][0]) << endl;
    } else if (dmin > arr[i][1]) {
      cout << (arr[i][1] - arr[i][0]) << endl;
    } else if (dmin >= arr[i][0] && dmax <= arr[i][1]) {
      cout << ((arr[i][1] - arr[i][0]) - (dmax - dmin)) << endl;
    } else if (dmin <= arr[i][0] && dmax <= arr[i][1]) {
      cout << (arr[i][1] - dmax) << endl;
    } else if (dmin >= arr[i][0] && dmax >= arr[i][1]) {
      cout << (dmin - arr[i][0]) << endl;
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}
