#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

template<unsigned MOD_> struct ModInt {
    static const unsigned MOD = MOD_;
    unsigned x;
    void undef() { x = (unsigned)-1; }
    bool isnan() const { return x == (unsigned)-1; }
    inline int geti() const { return (int)x; }
    ModInt() { x = 0; }
    ModInt(const ModInt &y) { x = y.x; }
    ModInt(int y) { if (y<0 || (int)MOD<=y) y %= (int)MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt(long long y) { if (y<0 || MOD<=y) y %= MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned long long y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt &operator+=(const ModInt y) { if ((x += y.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(const ModInt y) { if ((x -= y.x) & (1u<<31)) x += MOD; return *this; }
    ModInt &operator*=(const ModInt y) { x = (unsigned long long)x * y.x % MOD; return *this; }
    ModInt &operator/=(const ModInt y) { x = (unsigned long long)x * y.inv().x % MOD; return *this; }
    ModInt operator-() const { return (x ? MOD-x: 0); }

    ModInt inv() const { return pow(MOD-2); }
    ModInt pow(long long y) const {
	ModInt b = *this, r = 1;
	if (y < 0) { b = b.inv(); y = -y; }
	for (; y; y>>=1) {
	    if (y&1) r *= b;
	    b *= b;
	}
	return r;
    }

    ModInt extgcd() const {
	unsigned a = MOD, b = x; int u = 0, v = 1;
	while (b) {
	    int t = a / b;
	    a -= t * b; swap(a, b);
	    u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return ModInt(u);
    }

    friend ModInt operator+(ModInt x, const ModInt y) { return x += y; }
    friend ModInt operator-(ModInt x, const ModInt y) { return x -= y; }
    friend ModInt operator*(ModInt x, const ModInt y) { return x *= y; }
    friend ModInt operator/(ModInt x, const ModInt y) { return x *= y.inv(); }
    friend bool operator<(const ModInt x, const ModInt y) { return x.x < y.x; }
    friend bool operator==(const ModInt x, const ModInt y) { return x.x == y.x; }
    friend bool operator!=(const ModInt x, const ModInt y) { return x.x != y.x; }
};

const LL MOD = 1000000007;
//const LL MOD = 998244353;
typedef ModInt<MOD> Mint;
LL A, B, C, D;

struct Cmp {
    bool operator()(const pair<LL, LL> &x, const pair<LL, LL> &y) const {
	return x.first * y.second < x.second * y.first;
    }
} cmp;

int ord(LL x, LL y, LL z) {
    if ((x+1)*B < (y+1)*A && (x+1)*C < (z+1)*A) return 0;
    if ((y+1)*C < (z+1)*B) return 1;
    return 2;
}

void MAIN() {
    scanf("%lld%lld%lld%lld", &A, &B, &C, &D);

    LL x = 0, y = 0, z = 0;
    Mint ans = 0;
    {
	Mint xd = min(A-1, x+D) - max(0LL, x-D) + 1;
	Mint yd = min(B-1, y+D) - max(0LL, y-D) + 1;
	Mint zd = min(C-1, z+D) - max(0LL, z-D) + 1;
	ans += xd * yd * zd;
    }

    vector<pair<LL, LL> > E;
    REP (t, 3) {
	LL X;
	if (t == 0) X = A;
	if (t == 1) X = B;
	if (t == 2) X = C;

	if (X <= 2 * D + 10) {
	    for (int i=1; i<X; i++) E.emplace_back(i, X);
	} else {
	    for (int i=1; i<=D; i++) E.emplace_back(i, X);
	    for (int i=X-D-5; i<X; i++) E.emplace_back(i, X);
	}
    }
    sort(E.begin(), E.end(), cmp);

    EACH (e, E) {
	LL x1, y1, z1;
	if (e->second == A) {
	    x1 = e->first;
	    y1 = x1*B/A;
	    z1 = x1*C/A;
	} else if (e->second == B) {
	    y1 = e->first;
	    x1 = y1*A/B;
	    z1 = y1*C/B;
	} else {
	    z1 = e->first;
	    x1 = z1*A/C;
	    y1 = z1*B/C;
	}

	Mint xd = min(A-1, x+D)-max(0LL, x-D)+1;
	Mint yd = min(B-1, y+D)-max(0LL, y-D)+1;
	Mint zd = min(C-1, z+D)-max(0LL, z-D)+1;
	if (x1+D < A) ans += Mint(x1-x) * yd * zd;
	if (y1+D < B) ans += Mint(y1-y) * xd * zd;
	if (z1+D < C) ans += Mint(z1-z) * xd * yd;

	x = x1;
	y = y1;
	z = z1;
    }

    printf("%d\n", ans.geti());
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 10604