#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

ll dp[41][1<<16][2];

int main(int argc, char* argv[])
{
    int n,x,y,z;
    scanf("%d%d%d%d", &n, &x, &y, &z);

    int s=(1<<(x+y+z))+(1<<(y+z))+(1<<z);
    int s2=s/2;

    dp[0][0][0]=1;
    int i,j,p,k;
    for(i=0; i<n; i++) {
        for(j=0; j<(1<<16); j++) {
            for(p=0; p<2; p++) {
                if(dp[i][j][p]) {
                    for(k=1; k<=10; k++) {
                        ll tmp=((ll)((j<<1)+1)<<(k-1));
                        int flag=p;
                        if(flag==0 && (tmp&s2)==s2) {
                            flag=1;
                        }
                        int j2=tmp%(1<<16);
                        dp[i+1][j2][flag]=(dp[i+1][j2][flag]+dp[i][j][p])%MOD;              
                    }
                }
            }
        }
    }
    ll ans=0;
    for(j=0; j<(1<<16); j++) {
        ans=(ans+dp[n][j][1])%MOD;
    }
    printf("%lld\n", ans);

    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#define N 100010
#define mod 1000000007
#define ll long long
using namespace std;
ll fac[N],inv[N],f[N];
ll ksm(ll a,ll b=mod-2)
{
	ll ans=1;
	for(;b;b>>=1)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
int main()
{
	int n,l,r,lt,rt;
	scanf("%d%d%d%d%d",&n,&l,&r,&lt,&rt);
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=ksm(fac[n]);
	for(int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	f[0]=1;
	for(int i=l;i<=r;i++)
		for(int j=min(i*rt,n);j>=i*lt;j--)
		{
			ll u=ksm(inv[i],lt);
			int v=j-i*lt;
			for(int k=lt;k<=rt;k++)
			{
				f[j]=(f[j]+fac[j]*u%mod*inv[v]%mod*inv[k]%mod*f[v])%mod;
				v-=i,u=u*inv[i]%mod;
				if(v<0) break;
			}
		}
	printf("%d\n",f[n]);
	return 0;
}
