#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define forr(x,arr) for(auto&& x:arr) #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) _rep3(i,0,n) #define _rep3(i,a,b) for(int i=int(a);i=int(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() #define bit(n) (1LL<<(n)) #define sz(x) ((int)(x).size()) #define TEN(n) ((ll)(1e##n)) #define fst first #define snd second string DBG_DLM(int &i){return(i++==0?"":", ");} #define DBG_B(exp){int i=0;os<<"{";{exp;}os<<"}";return os;} templateostream&operator<<(ostream&os,vectorv); templateostream&operator<<(ostream&os,setv); templateostream&operator<<(ostream&os,queueq); templateostream&operator<<(ostream&os,priority_queueq); templateostream&operator<<(ostream&os,pairp); templateostream&operator<<(ostream&os,mapmp); templateostream&operator<<(ostream&os,unordered_mapmp); templatevoid DBG(ostream&os,TPL t){} templatevoid DBG(ostream&os,TPL t){os<<(I==0?"":", ")<(t);DBG(os,t);} templatevoid DBG(ostream&os,pairp,string delim){os<<"("<ostream&operator<<(ostream&os,tuplet){os<<"(";DBG<0,tuple,Ts...>(os,t);os<<")";return os;} templateostream&operator<<(ostream&os,pairp){DBG(os,p,", ");return os;} templateostream&operator<<(ostream&os,vectorv){DBG_B(forr(t,v){os<ostream&operator<<(ostream&os,sets){DBG_B(forr(t,s){os<ostream&operator<<(ostream&os,queueq){DBG_B(for(;q.size();q.pop()){os<ostream&operator<<(ostream&os,priority_queueq){DBG_B(for(;q.size();q.pop()){os<ostream&operator<<(ostream&os,mapm){DBG_B(forr(p,m){os<");});} templateostream&operator<<(ostream&os,unordered_mapm){DBG_B(forr(p,m){os<");});} #define DBG_OVERLOAD(_1,_2,_3,_4,_5,_6,macro_name,...)macro_name #define DBG_LINE(){char s[99];sprintf(s,"line:%3d | ",__LINE__);cerr<;using pll=pair;using pil=pair;using pli=pair; using vs=vector;using vvs=vector;using vvvs=vector; using vb=vector;using vvb=vector;using vvvb=vector; using vi=vector;using vvi=vector;using vvvi=vector; using vl=vector;using vvl=vector;using vvvl=vector; using vd=vector;using vvd=vector;using vvvd=vector; using vpii=vector;using vvpii=vector;using vvvpii=vector; templatebool amax(A&a,const B&b){return b>a?a=b,1:0;} templatebool amin(A&a,const B&b){return b>l;return l;} string rs(){string s;cin>>s;return s;} template struct Mint { int x; Mint() : x(0) {} Mint(int y) : x(y >= 0 ? y % MOD : MOD - (-y) % MOD) {} Mint(int64_t sll) : x(sll % MOD) { if (x < 0) x += MOD; } Mint &operator+=(const Mint &rhs){ if((x += rhs.x) >= MOD) x -= MOD; return *this; } Mint &operator-=(const Mint &rhs){ if((x += MOD - rhs.x) >= MOD) x -= MOD; return *this; } Mint &operator*=(const Mint &rhs){ x = 1LL*x*rhs.x % MOD; return *this; } Mint &operator/=(const Mint &rhs){ x = (1LL*x*rhs.inv().x) % MOD; return *this; } Mint operator-() const { return Mint(-x); } Mint operator+(const Mint &rhs) const { return Mint(*this) += rhs; } Mint operator-(const Mint &rhs) const { return Mint(*this) -= rhs; } Mint operator*(const Mint &rhs) const { return Mint(*this) *= rhs; } Mint operator/(const Mint &rhs) const { return Mint(*this) /= rhs; } bool operator<(const Mint &rhs) const { return x < rhs.x; } Mint inv() const { signed a = x, b = MOD, u = 1, v = 0, t; while (b) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } return Mint(u); } Mint operator^(uint64_t t) const { Mint e = *this, res = 1; for(; t; e *= e, t>>=1) if (t & 1) res *= e; return res; } }; template ostream &operator<<(ostream &os, const Mint &rhs) { return os << rhs.x; } template istream &operator>>(istream &is, Mint &rhs) { int64_t s; is >> s; rhs = Mint(s); return is; }; const int mod = 1e9+7; using mint = Mint; using vm=vector;using vvm=vector;using vvvm=vector; using vvvvm = vector; const int SET_FACT_MAX = 10000; mint fact[SET_FACT_MAX]; mint revFact[SET_FACT_MAX]; void setFact() { const int N = SET_FACT_MAX; fact[0] = 1; for (int i = 1; i < N; i++) { fact[i] = fact[i - 1] * i; } revFact[N - 1] = fact[N - 1] ^ (mod - 2); for (int i = N - 2; i >= 0; i--) { revFact[i] = revFact[i + 1] * (i + 1); } } mint nPr(int n, int r) { return n >= r ? fact[n] * revFact[n - r] : 0; } mint nCr(int n, int r) { return nPr(n, r) * revFact[r]; } mint nHr(int n, int r) { return n == 0 && r == 0 ? 1 : nCr(n + r - 1, r); } mint solve(int n, int R, int G, int B) { setFact(); int T = R+G+B; int ma = max({R, G, B}); int mi = min({R, G, B}); int mu = T - mi - ma; R = mi; G = mu; B = ma; if (T == 0) return 1; out(n, R, G, B); mint ans = 0; vector> K; rep(k, mi, n+1) { mint s = 0; rep(lef, n) { int m = n - lef; int l = m - T - (k - 1); if (l < 0) break; s += nCr(l+k-1, l); } int x = T - k; int y = k - x; if (x < 0 || y < 0) { continue; } K.emplace_back(k, s); } reverse(all(K)); vm ords(ma+1); rep(i, ma+1) { rep(o1, i+1) { ords[i] += nCr(i, o1); } } forr(ks, K) { int k = ks.fst; mint s = ks.snd; int x = T - k; int y = k - x; if (s.x) { s *= nCr(k, x); rep(rg, x+1) { rep(rb, (x-rg)+1) { int gb = x - rg - rb; int r1 = R - rg - rb; int g1 = G - rg - gb; int b1 = B - rb - gb; if (gb >= 0 && r1 >= 0 && g1 >= 0 && b1 >= 0) { mint cand = s * nCr(x, rg) * nCr(x - rg, rb) * nCr(y, r1) * nCr(y - r1, g1); cand *= ords[rg]; cand *= ords[rb]; cand *= ords[gb]; ans += cand; } } } } } return ans; } void Main() { int n = ri(), R = ri(), G = ri(), B = ri(); cout << solve(n, R, G, B) << endl; } signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }