/+ dub.sdl:
    name "E"
    dependency "dcomp" version=">=0.7.3"
+/
 
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
 
// import dcomp.algorithm;
// import dcomp.modint;
alias Mint = ModInt!(10^^9 + 7);
 
long A, B, C, D;
long[3] H;
 
Mint succ(long[3] p, long d) {
    //add p[d] + D + 1
    if (p[d] + D + 1 >= H[d]) return Mint(0);
    Mint f = 1;
    foreach (i; 0..3) {
        if (i == d) continue;
        long lw = max(0L, p[i] - D);
        long hi = min(H[i], p[i] + D + 1);
        f *= Mint(hi - lw);
    }
    return f;
}
 
Mint solve() {
    Mint fi = 1;
    foreach (i; 0..3) fi *= Mint(min(H[i], D+1));
 
    if (A+B+C < 3*10^^7) {
        long[3] p = [0, 0, 0];
        while (true) {
            bool last = true;
            foreach (i; 0..3) {
                if (p[i]+1 < H[i]) {
                    last = false;
                    break;
                }
            }
            if (last) break;
 
            long[3][3] v;
            foreach (i; 0..3) {
                v[i] = [p[i]+1, H[i], i];
            }
 
            auto nxd = v[].minimum!((x, y) => x[0]*y[1] < x[1]*y[0]);
 
            int nx = nxd[2].to!int;
            fi += succ(p, nx);
            p[nx]++;
        }
 
        return fi;
    }
 
    long[3] L, R;
    {
        long[3] p = [0, 0, 0];
        foreach (ph; 0..10^^7) {
            long[3][3] v;
            foreach (i; 0..3) {
                v[i] = [p[i]+1, H[i], i];
            }
 
            auto nxd = v[].minimum!((x, y) => x[0]*y[1] < x[1]*y[0]);
 
            int nx = nxd[2].to!int;
            fi += succ(p, nx);
            p[nx]++;
        }
        L = p;
    }
    {
        long[3] p = [A-1, B-1, C-1];
        foreach (ph; 0..3*10^^7) {
            long[3][3] v;
            foreach (i; 0..3) {
                v[i] = [p[i], H[i], i];
            }
 
            auto nxd = v[].maximum!((x, y) => x[0]*y[1] < x[1]*y[0]);
 
            int nx = nxd[2].to!int;
            p[nx]--;
            fi += succ(p, nx);
        }
        R = p;
    }
 
    if (L[0] > D+100 && R[0] < H[0] - D - 100) {
        //big big big
        foreach (d; 0..3) {
            fi += Mint(2*D + 1) * Mint(2*D + 1) * Mint(R[d] - L[d]);
        }
        return fi;
    }
    
    if (L[1] > D+100 && R[1] < H[1] - D - 100) {
        //small big big
        long[3] p = L;
        while (true) {
            bool last = true;
            foreach (i; 0..3) {
                if (p[i] < R[i]) {
                    last = false;
                    break;
                }
            }
            if (last) break;
 
            if (p[0] == R[0]) {
                fi += succ(p, 1) * Mint(R[1] - p[1]);
                fi += succ(p, 2) * Mint(R[2] - p[2]);
                break;
            }
 
            long[3][3] v;
            foreach (i; 0..3) {
                v[i] = [p[i]+1, H[i], i];
            }
 
            auto nxd = v[].minimum!((x, y) => x[0]*y[1] < x[1]*y[0]);
 
            int nx = nxd[2].to!int;
            if (nx == 0) {
                fi += succ(p, nx);
                p[nx]++;
                continue;
            }
            long f1 = (p[0]+1)*H[1] / H[0];
            long f2 = (p[0]+1)*H[2] / H[0];
            fi += succ(p, 1) * Mint(f1 - p[1]);
            fi += succ(p, 2) * Mint(f2 - p[2]);
            p[1] = f1;
            p[2] = f2;
            //f1
        }
//        assert(false);
        return fi;
    }
    //small small big
 
    long[3] p = L;
    while (true) {
        bool last = true;
        foreach (i; 0..3) {
            if (p[i] < R[i]) {
                last = false;
                break;
            }
        }
        if (last) break;
 
        if (p[0] == R[0] && p[1] == R[1]) {
            fi += succ(p, 2) * Mint(R[2] - p[2]);
            break;
        }
 
        long[3][3] v;
        foreach (i; 0..3) {
            v[i] = [p[i]+1, H[i], i];
        }
 
        auto nxd = v[].minimum!((x, y) => x[0]*y[1] < x[1]*y[0]);
 
        int nx = nxd[2].to!int;
        if (nx == 0 || nx == 1) {
            fi += succ(p, nx);
            p[nx]++;
            continue;
        }
        long f1 = (p[0]+1)*H[2] / H[0];
        long f2 = (p[1]+1)*H[2] / H[1];
        long f = min(f1, f2);
        fi += succ(p, 2) * Mint(f - p[2]);
        p[2] = f;
        //f1
    }
    
/*    long[3] p = L;
    while (true) {
        bool last = true;
        foreach (i; 0..3) {
            if (p[i]+1 < H[i]) {
                last = false;
                break;
            }
        }
        if (last) break;
 
        long[3][3] v;
        foreach (i; 0..3) {
            v[i] = [p[i]+1, H[i], i];
        }
 
        auto nxd = v[].minimum!((x, y) => x[0]*y[1] < x[1]*y[0]);
 
        int nx = nxd[2].to!int;
        fi += succ(p, nx);
        p[nx]++;
    }*/
 
 
 
 
//    fi += (R[2] - L[2]);
    return fi;
}
 
int main() {
    Scanner sc = new Scanner(stdin);
    sc.read(A, B, C, D);
    H = [A, B, C];
    H[].sort!"a<b";
    writeln(solve());
    return 0;
}
/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/modint.d */
// module dcomp.modint;
 
// import dcomp.numeric.primitive;
 
 
struct ModInt(uint MD) if (MD < int.max) {
    import std.conv : to;
    uint v;
    this(int v) {this(long(v));}
    this(long v) {this.v = (v%MD+MD)%MD;}
    static auto normS(uint x) {return (x<MD)?x:x-MD;}
    static auto make(uint x) {ModInt m; m.v = x; return m;}
     
    auto opBinary(string op:"+")(ModInt r) const {return make(normS(v+r.v));}
     
    auto opBinary(string op:"-")(ModInt r) const {return make(normS(v+MD-r.v));}
     
    auto opBinary(string op:"*")(ModInt r) const {return make((ulong(v)*r.v%MD).to!uint);}
     
    auto opBinary(string op:"/")(ModInt r) const {return this*inv(r);}
    auto opOpAssign(string op)(ModInt r) {return mixin ("this=this"~op~"r");}
     
    static ModInt inv(ModInt x) {return ModInt(extGcd!int(x.v, MD)[0]);}
    string toString() {return v.to!string;}
}
 
 
 
 
 
 
 
struct DModInt(string name) {
    import std.conv : to;
    static uint MD;
    uint v;
    this(int v) {this(long(v));}
    this(long v) {this.v = ((v%MD+MD)%MD).to!uint;}
    static auto normS(uint x) {return (x<MD)?x:x-MD;}
    static auto make(uint x) {DModInt m; m.MD = MD; m.v = x; return m;}
     
    auto opBinary(string op:"+")(DModInt r) const {return make(normS(v+r.v));}
     
    auto opBinary(string op:"-")(DModInt r) const {return make(normS(v+MD-r.v));}
     
    auto opBinary(string op:"*")(DModInt r) const {return make((ulong(v)*r.v%MD).to!uint);}
     
    auto opBinary(string op:"/")(DModInt r) const {return this*inv(r);}
    auto opOpAssign(string op)(DModInt r) {return mixin ("this=this"~op~"r");}
     
    static DModInt inv(DModInt x) {
        return DModInt(extGcd!int(x.v, MD)[0]);
    }
    string toString() {return v.to!string;}
}
 
 
 
 
 
 
template isModInt(T) {
    const isModInt =
        is(T : ModInt!MD, uint MD) || is(S : DModInt!S, string s);
}
 
 
T[] factTable(T)(size_t length) if (isModInt!T) {
    import std.range : take, recurrence;
    import std.array : array;
    return T(1).recurrence!((a, n) => a[n-1]*T(n)).take(length).array;
}
 
 
T[] invFactTable(T)(size_t length) if (isModInt!T) {
    import std.algorithm : map, reduce;
    import std.range : take, recurrence, iota;
    import std.array : array;
    auto res = new T[length];
    res[$-1] = T(1) / iota(1, length).map!T.reduce!"a*b";
    foreach_reverse (i, v; res[0..$-1]) {
        res[i] = res[i+1] * T(i+1);
    }
    return res;
}
 
T[] invTable(T)(size_t length) if (isModInt!T) {
    auto f = factTable!T(length);
    auto invf = invFactTable!T(length);
    auto res = new T[length];
    foreach (i; 1..length) {
        res[i] = invf[i] * f[i-1];
    }
    return res;
}
 
 
/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/numeric/primitive.d */
// module dcomp.numeric.primitive;
 
import std.traits;
import std.bigint;
 
 
Unqual!T pow(T, U)(T x, U n) if (!isFloatingPoint!T && (isIntegral!U || is(U == BigInt))) {
    return pow(x, n, T(1));
}
 
 
Unqual!T pow(T, U, V)(T x, U n, V e)
if ((isIntegral!U || is(U == BigInt)) && is(Unqual!T == Unqual!V)) {
    Unqual!T b = x, v = e;
    Unqual!U m = n;
    while (m) {
        if (m & 1) v *= b;
        b *= b;
        m /= 2;
    }
    return v;
}
 
 
 
 
T lcm(T)(in T a, in T b) {
    import std.numeric : gcd;
    return a / gcd(a,b) * b;
}
 
 
 
 
 
 
T[3] extGcd(T)(in T a, in T b) 
if (!isIntegral!T || isSigned!T)  
{
    if (b==0) {
        return [T(1), T(0), a];
    } else {
        auto e = extGcd(b, a%b);
        return [e[1], e[0]-a/b*e[1], e[2]];
    }
}
 
 
 
/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/algorithm.d */
// module dcomp.algorithm;
 
import std.range.primitives;
import std.traits : isFloatingPoint, isIntegral;
 
 
T binSearch(alias pred, T)(T l, T r) if (isIntegral!T) {
    while (r-l > 1) {
        T md = (l+r)/2;
        if (!pred(md)) l = md;
        else r = md;
    }
    return r;
}
 
 
T binSearch(alias pred, T)(T l, T r, int cnt = 60) if (isFloatingPoint!T) {
    foreach (i; 0..cnt) {
        T md = (l+r)/2;
        if (!pred(md)) l = md;
        else r = md;
    }
    return r;
}
 
 
 
 
 
E minimum(alias pred = "a < b", Range, E = ElementType!Range)(Range range, E seed)
if (isInputRange!Range && !isInfinite!Range) {
    import std.algorithm, std.functional;
    return reduce!((a, b) => binaryFun!pred(a, b) ? a : b)(seed, range);
}
 
 
ElementType!Range minimum(alias pred = "a < b", Range)(Range range) {
    assert(!range.empty, "range must not empty");
    auto e = range.front; range.popFront;
    return minimum!pred(range, e);
}
 
 
 
 
 
E maximum(alias pred = "a < b", Range, E = ElementType!Range)(Range range, E seed)
if (isInputRange!Range && !isInfinite!Range) {
    import std.algorithm, std.functional;
    return reduce!((a, b) => binaryFun!pred(a, b) ? b : a)(seed, range);
}
 
 
ElementType!Range maximum(alias pred = "a < b", Range)(Range range) {
    assert(!range.empty, "range must not empty");
    auto e = range.front; range.popFront;
    return maximum!pred(range, e);
}
 
 
 
 
 
Rotator!Range rotator(Range)(Range r) {
    return Rotator!Range(r);
}
 
 
struct Rotator(Range)
if (isForwardRange!Range && hasLength!Range) {
    size_t cnt;
    Range start, now;
    this(Range r) {
        cnt = 0;
        start = r.save;
        now = r.save;
    }
    this(this) {
        start = start.save;
        now = now.save;
    }
    @property bool empty() {
        return now.empty;
    }
    @property auto front() {
        assert(!now.empty);
        import std.range : take, chain;
        return chain(now, start.take(cnt));
    }
    @property Rotator!Range save() {
        return this;
    }
    void popFront() {
        cnt++;
        now.popFront;
    }
}
 
 
 
/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/scanner.d */
// module dcomp.scanner;
 
// import dcomp.array;
 
 
class Scanner {
    import std.stdio : File;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeChar, isStaticArray, isArray; 
    import std.algorithm : map;
    File f;
    this(File f) {
        this.f = f;
    }
    char[512] lineBuf;
    char[] line;
    private bool succW() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (!line.empty && line.front.isWhite) {
            line.popFront;
        }
        return !line.empty;
    }
    private bool succ() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (true) {
            while (!line.empty && line.front.isWhite) {
                line.popFront;
            }
            if (!line.empty) break;
            line = lineBuf[];
            f.readln(line);
            if (!line.length) return false;
        }
        return true;
    }
 
    private bool readSingle(T)(ref T x) {
        import std.algorithm : findSplitBefore;
        import std.string : strip;
        import std.conv : parse;
        if (!succ()) return false;
        static if (isArray!T) {
            alias E = ElementType!T;
            static if (isSomeChar!E) {
                 
                 
                auto r = line.findSplitBefore(" ");
                x = r[0].strip.dup;
                line = r[1];
            } else static if (isStaticArray!T) {
                foreach (i; 0..T.length) {
                    bool f = succW();
                    assert(f);
                    x[i] = line.parse!E;
                }
            } else {
                FastAppender!(E[]) buf;
                while (succW()) {
                    buf ~= line.parse!E;
                }
                x = buf.data;
            }
        } else {
            x = line.parse!T;
        }
        return true;
    }
    int read(T, Args...)(ref T x, auto ref Args args) {
        if (!readSingle(x)) return 0;
        static if (args.length == 0) {
            return 1;
        } else {
            return 1 + read(args);
        }
    }
}
 
 
 
 
 
 
/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/foundation.d */
// module dcomp.foundation;
 
static if (__VERSION__ <= 2070) {
    /*
    Copied by https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d
    Copyright: Andrei Alexandrescu 2008-.
    License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
    */
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            import std.algorithm : reduce;
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                import std.typecons : tuple;
                return reduce!fun(tuple(seed), r);
            }
        }
    }
     
}
/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/array.d */
// module dcomp.array;
 
 
T[N] fixed(T, size_t N)(T[N] a) {return a;}
 
 
 
 
 
struct FastAppender(A, size_t MIN = 4) {
    import std.algorithm : max;
    import std.conv;
    import std.range.primitives : ElementEncodingType;
    import core.stdc.string : memcpy;
 
    private alias T = ElementEncodingType!A;
    private T* _data;
    private uint len, cap;
     
    @property size_t length() const {return len;}
    bool empty() const { return len == 0; }
     
    void reserve(size_t nlen) {
        import core.memory : GC;
        if (nlen <= cap) return;
        
        void* nx = GC.malloc(nlen * T.sizeof);
 
        cap = nlen.to!uint;
        if (len) memcpy(nx, _data, len * T.sizeof);
        _data = cast(T*)(nx);
    }
    void free() {
        import core.memory : GC;
        GC.free(_data);
    }
     
    void opOpAssign(string op : "~")(T item) {
        if (len == cap) {
            reserve(max(MIN, cap*2));
        }
        _data[len++] = item;
    }
     
    void insertBack(T item) {
        this ~= item;
    }
     
    void removeBack() {
        len--;
    }
     
    void clear() {
        len = 0;
    }
    ref inout(T) back() inout { assert(len); return _data[len-1]; }
    ref inout(T) opIndex(size_t i) inout { return _data[i]; }
     
    T[] data() {
        return (_data) ? _data[0..len] : null;
    }
}
 
 
 
 
/*
This source code generated by dcomp and include dcomp's source code.
dcomp's Copyright: Copyright (c) 2016- Kohei Morita. (https://github.com/yosupo06/dcomp)
dcomp's License: MIT License(https://github.com/yosupo06/dcomp/blob/master/LICENSE.txt)
*/

Measured memory_bytes: 256