import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto T = readln.chomp.to!int;
    while (T--) {
        auto s = readln.split.map!(to!long);
        auto a = s[0];
        auto b = s[1];
        auto c = s[2];
        auto r = s[3];
        if (a > b) swap(a, b);
        auto u = c - r;
        auto v = c + r;
        if (u >= b || v <= a) {
            writeln(b - a);
        } else {
            u = max(u, a);
            v = min(v, b);
            writeln(b - a - (v - u));
        }
    }
}