#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,R,G,B,S; int mo=1000000007; const int CN=4001; ll C[CN][CN]; int p2[3050]; inline int mulmod(int a,int b,int mo) { int d,r; if(a==0 || b==0) return 0; if(a==1 || b==1) return max(a,b); __asm__("mull %4;" "divl %2" : "=d" (r), "=a" (d) : "r" (mo), "a" (a), "d" (b)); return r; } void solve() { int i,j,k,l,r,x,y; string s; FOR(i,CN) for(j=0;j<=i;j++) C[i][j]=(j==0||j==i)?1:(C[i-1][j-1]+C[i-1][j])%mo; p2[0]=1; FOR(i,3030) p2[i+1]=1LL*p2[i]*2%mo; cin>>N>>R>>G>>B; S=N-R-G-B; int slot=S+1; ll ret=0; for(int s2=0;s2<=slot;s2++) { int s1=R+G+B-s2*2; int s0=slot-s1-s2; if(s1<0 || s0<0) continue; ll pat=1LL*C[slot][s2]*C[s0+s1][s0]%mo; ll hoge=0; for(int r=0;r<=min(R,s1);r++) { for(int g=0;g<=G && r+g<=s1;g++) { int b=s1-r-g; if(b>B) continue; int r2=R-r; int g2=G-g; int b2=B-b; if((r2+b2+g2)%2) continue; if(r2*2>r2+b2+g2) continue; if(g2*2>r2+b2+g2) continue; if(b2*2>r2+b2+g2) continue; /* ll a=C[s1][r]*C[g+b][b]%mo; (a*=C[s2][r2]*C[r2][b2-(s2-r2)]%mo)%=mo; hoge += a*p2[s2]%mo; */ int a=mulmod(C[s1][r],C[g+b][b],mo); int c=mulmod(C[s2][r2],C[r2][b2-(s2-r2)],mo); hoge += mulmod(mulmod(a,c,mo),p2[s2],mo); } } (ret += pat*(hoge%mo))%=mo; } cout<