stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#pragma GCC optimize(2) 

#include<bits/stdc++.h>

#define rg register

#define il inline

using namespace std;

typedef long long ll;

const ll mod=1e9+7;

int n,x,y,z,ok,all;

ll ans=1,dp[45][1<<18];

int main(){

	scanf("%d%d%d%d",&n,&x,&y,&z);

	for(int i=1;i<=n;++i)ans=10*ans%mod;

	all=(1<<x+y+z)-1;

	ok=(1<<x+y+z-1)|(1<<y+z-1)|(1<<z-1);

	dp[0][0]=1;

	for(int i=1;i<=n;++i)

		for(int j=0;j<=all;++j)

			if(dp[i-1][j])

				for(int k=1;k<11;++k){

					int s=((j<<k)|(1<<k-1))&all;

					if((s&ok)==ok)continue;

					(dp[i][s]+=dp[i-1][j])%=mod;

				}

	for(int i=0;i<=all;++i)(ans+=mod-dp[n][i])%=mod;

	printf("%d\n",ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.326164937469683x):
#include <cstdio>



const int MAXN = 40, MAXL = 17, MOD = 1e9 + 7;

int n, x, y, z, f[2][1 << MAXL];



inline void add_eq ( int& a, const int b ) { if ( ( a += b ) >= MOD ) a -= MOD; }



int main () {

	scanf ( "%d %d %d %d", &n, &x, &y, &z );

	int all = ( 1 << x + y + z ) - 1, ans = 1;

	int haiku = ( 1 << x + y + z >> 1 ) | ( 1 << y + z >> 1 ) | ( 1 << z >> 1 );

	f[0][0] = 1;

	for ( int i = 0, t = 0; i < n; ++ i, t ^= 1, ans = ans * 10ll % MOD ) {

		for ( int s = 0; s <= all; ++ s ) {

			int& cur = f[t][s];

			if ( ! cur ) continue;

			for ( int j = 1, trs; j <= 10; ++ j ) {

				trs = ( s << j | ( 1 << j >> 1 ) ) & all;

				if ( ( trs & haiku ) ^ haiku ) add_eq ( f[t ^ 1][trs], cur );

			}

			cur = 0;

		}

	}

	int sub = 0;

	for ( int i = 0; i <= all; ++ i ) add_eq ( sub, f[n & 1][i] );

	printf ( "%d\n", ( ans - sub + MOD ) % MOD );

	return 0;

}
// Slower C++ solution:
// ===================================

//   author: M_sea

//   website: http://m-sea-blog.com/

// ===================================

#include <algorithm>

#include <iostream>

#include <cstdlib>

#include <cstring>

#include <cstdio>

#include <cmath>

#define re register

using namespace std;



inline int read() {

    int X=0,w=1; char c=getchar();

    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }

    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();

    return X*w;

}



const int mod=1e9+7;

inline int qpow(int a,int b) { int c=1;

    for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod;

    return c;

}



int n,X,Y,Z;

int dp[45][1<<17];



int main() {

    n=read(),X=read(),Y=read(),Z=read();

    int Haiku=(1<<(Z-1))|(1<<(Y+Z-1))|(1<<(X+Y+Z-1));

    int lim=(1<<(X+Y+Z))-1;

    dp[0][0]=1;

    for (re int i=0;i<n;++i)

        for (re int S=0;S<=lim;++S) {

            if (!dp[i][S]) continue;

            for (re int j=1;j<=10;++j) {

                int T=((S<<j)|(1<<(j-1)))&lim;

                if ((T&Haiku)!=Haiku)

                    dp[i+1][T]=(dp[i+1][T]+dp[i][S])%mod;

            }

        }

    int ans=0;

    for (re int i=0;i<=lim;++i) ans=(ans+dp[n][i])%mod;

    printf("%d\n",(qpow(10,n)-ans+mod)%mod);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.630185371196908x):
#include <cstdio>



const int MAXN = 40, MAXL = 17, MOD = 1e9 + 7;

int n, x, y, z, f[2][1 << MAXL];



inline void add_eq ( int& a, const int b ) { if ( ( a += b ) >= MOD ) a -= MOD; }



int main () {

	scanf ( "%d %d %d %d", &n, &x, &y, &z );

	int all = ( 1 << x + y + z ) - 1, ans = 1;

	int haiku = ( 1 << x + y + z >> 1 ) | ( 1 << y + z >> 1 ) | ( 1 << z >> 1 );

	f[0][0] = 1;

	for ( int i = 0, t = 0; i < n; ++ i, t ^= 1, ans = ans * 10ll % MOD ) {

		for ( int s = 0; s <= all; ++ s ) {

			int& cur = f[t][s];

			if ( ! cur ) continue;

			for ( int j = 1, trs; j <= 10; ++ j ) {

				trs = ( s << j | ( 1 << j >> 1 ) ) & all;

				if ( ( trs & haiku ) ^ haiku ) add_eq ( f[t ^ 1][trs], cur );

			}

			cur = 0;

		}

	}

	int sub = 0;

	for ( int i = 0; i <= all; ++ i ) add_eq ( sub, f[n & 1][i] );

	printf ( "%d\n", ( ans - sub + MOD ) % MOD );

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

using namespace std;

const ll N=42, Max=(1<<17)+10, MOD=1e9+7;

ll n, x, y, z, f[N][Max], sum=1, ans;

inline ll M(ll a){return a%MOD;}



void work(){

	for(int i = 0; i < n; i++) sum = M(sum*10);

	ll cnt = (1<<x+y+z) -1;

	ll tot = (1<<x-1) | (1<<x+y-1) | (1<<x+y+z-1); 

	f[0][0] = 1;

	for(int i = 1; i <= n; i++) 

		for(int j = 0; j <= cnt; j++) 

			for(int h = 1;h <= 10; h++){

				ans = (j<<h)|(1<<h-1);

				ans &= cnt;

				if((ans&tot)!=tot) f[i][ans] = M(f[i][ans]+f[i-1][j]);

			}

	for(int i = 0; i <= cnt; i++)

		sum = M(sum-f[n][i]+MOD);

}



int main(){

	scanf("%lld%lld%lld%lld",&n,&x,&y,&z);

	work();

	printf("%lld",sum);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 6.488450875159619x):
#include <cstdio>



const int MAXN = 40, MAXL = 17, MOD = 1e9 + 7;

int n, x, y, z, f[2][1 << MAXL];



inline void add_eq ( int& a, const int b ) { if ( ( a += b ) >= MOD ) a -= MOD; }



int main () {

	scanf ( "%d %d %d %d", &n, &x, &y, &z );

	int all = ( 1 << x + y + z ) - 1, ans = 1;

	int haiku = ( 1 << x + y + z >> 1 ) | ( 1 << y + z >> 1 ) | ( 1 << z >> 1 );

	f[0][0] = 1;

	for ( int i = 0, t = 0; i < n; ++ i, t ^= 1, ans = ans * 10ll % MOD ) {

		for ( int s = 0; s <= all; ++ s ) {

			int& cur = f[t][s];

			if ( ! cur ) continue;

			for ( int j = 1, trs; j <= 10; ++ j ) {

				trs = ( s << j | ( 1 << j >> 1 ) ) & all;

				if ( ( trs & haiku ) ^ haiku ) add_eq ( f[t ^ 1][trs], cur );

			}

			cur = 0;

		}

	}

	int sub = 0;

	for ( int i = 0; i <= all; ++ i ) add_eq ( sub, f[n & 1][i] );

	printf ( "%d\n", ( ans - sub + MOD ) % MOD );

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long

using namespace std; 

const int N=50,M=(1<<17)+5,mod=1e9+7; 

int n,x,y,z,st,dp[N][M],sum=1,k,ans;

signed main(){

	scanf("%lld%lld%lld%lld",&n,&x,&y,&z); 

	st=((1<<(x+y+z-1)))|(1<<(y+z-1))|(1<<(z-1));

	dp[0][0]=1;

	for(int i=1;i<=n;i++){ 

		sum=sum*10%mod; 

		for(int S=0;S<(1<<(x+y+z));S++)

			if(dp[i-1][S]&&(S&st)!=st)

				for(int c=1;c<=10;c++){ 

					k=((S<<c)|(1<<(c-1)))&((1<<(x+y+z))-1);

					dp[i][k]=(dp[i][k]+dp[i-1][S])%mod;

				} 

	} 

	for(int S=0;S<(1<<(x+y+z));S++)

		if((S&st)!=st) ans=(ans+dp[n][S])%mod;

	printf("%lld\n",(sum-ans+mod)%mod);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.2569212526838527x):
#include <cstdio>



const int MAXN = 40, MAXL = 17, MOD = 1e9 + 7;

int n, x, y, z, f[2][1 << MAXL];



inline void add_eq ( int& a, const int b ) { if ( ( a += b ) >= MOD ) a -= MOD; }



int main () {

	scanf ( "%d %d %d %d", &n, &x, &y, &z );

	int all = ( 1 << x + y + z ) - 1, ans = 1;

	int haiku = ( 1 << x + y + z >> 1 ) | ( 1 << y + z >> 1 ) | ( 1 << z >> 1 );

	f[0][0] = 1;

	for ( int i = 0, t = 0; i < n; ++ i, t ^= 1, ans = ans * 10ll % MOD ) {

		for ( int s = 0; s <= all; ++ s ) {

			int& cur = f[t][s];

			if ( ! cur ) continue;

			for ( int j = 1, trs; j <= 10; ++ j ) {

				trs = ( s << j | ( 1 << j >> 1 ) ) & all;

				if ( ( trs & haiku ) ^ haiku ) add_eq ( f[t ^ 1][trs], cur );

			}

			cur = 0;

		}

	}

	int sub = 0;

	for ( int i = 0; i <= all; ++ i ) add_eq ( sub, f[n & 1][i] );

	printf ( "%d\n", ( ans - sub + MOD ) % MOD );

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define int long long

namespace Fread {

	const int MAXN=1<<20;

	char buf[MAXN],*S,*T;

	inline char getchar() {

		if (S==T) {

			T=(S=buf)+fread(buf,1,MAXN,stdin);

			if (S==T) return EOF;

		}

		return *S++;

	}

}

inline int read() {

	int x(0),neg(1);

	char ch=getchar();

	while(!isdigit(ch)) {

		if (ch=='-') neg=-1;

		ch=getchar();

	}

	while(isdigit(ch)) {

		x=(x<<1)+(x<<3)+(ch-'0');

		ch=getchar();

	}

	return x*neg;

}

#ifdef ONLINE_JUDGE

	#define getchar Fread::getchar

#endif

#define pb push_back

#define mp make_pair

int n,x,y,z;

int dp[45][1<<18];

const int mod=1e9+7;

inline int qpow(int x,int y) {

	int res=1ll;

	while(y) {

		if (y&1) res=res*x%mod;

		x=x*x%mod;

		y>>=1; 

	}

	return res;

} 

//130624

/*

int cnt;

inline void dfs(int sum) {

	if (sum>17) return ;

	++cnt;

	for (int i=1;i<=10;++i) dfs(sum+i);

}

*/

signed main() {

//	freopen(".in","r",stdin);

//	freopen(".out","w",stdout);

/*

	cnt=0;

	dfs(0);

	cout<<cnt<<'\n';

*/

	n=read(),x=read(),y=read(),z=read();

	int pnt=((1<<(x+y+z-1))|(1<<(y+z-1))|(1<<(z-1)));

//	cout<<pnt<<'\n';

	int tot=(1<<(x+y+z))-1;

	int ans=qpow(10,n);

	dp[0][0]=1;

	for (int i=1;i<=n;++i) {

		for (int j=0;j<=tot;++j) {

			if (dp[i-1][j]==0) continue;

			for (int k=1;k<=10;++k) {

				int now=((j<<k)+(1<<k-1))&tot;

				if ((now&pnt)!=pnt) {

					dp[i][now]=(dp[i][now]+dp[i-1][j])%mod;

				}

			}

		}

	}

	for (int i=0;i<=tot;++i) {

		ans=(ans-dp[n][i]+mod)%mod;

	}

	printf("%lld\n",ans); 

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.0051254241569128x):
#include <cstdio>



const int MAXN = 40, MAXL = 17, MOD = 1e9 + 7;

int n, x, y, z, f[2][1 << MAXL];



inline void add_eq ( int& a, const int b ) { if ( ( a += b ) >= MOD ) a -= MOD; }



int main () {

	scanf ( "%d %d %d %d", &n, &x, &y, &z );

	int all = ( 1 << x + y + z ) - 1, ans = 1;

	int haiku = ( 1 << x + y + z >> 1 ) | ( 1 << y + z >> 1 ) | ( 1 << z >> 1 );

	f[0][0] = 1;

	for ( int i = 0, t = 0; i < n; ++ i, t ^= 1, ans = ans * 10ll % MOD ) {

		for ( int s = 0; s <= all; ++ s ) {

			int& cur = f[t][s];

			if ( ! cur ) continue;

			for ( int j = 1, trs; j <= 10; ++ j ) {

				trs = ( s << j | ( 1 << j >> 1 ) ) & all;

				if ( ( trs & haiku ) ^ haiku ) add_eq ( f[t ^ 1][trs], cur );

			}

			cur = 0;

		}

	}

	int sub = 0;

	for ( int i = 0; i <= all; ++ i ) add_eq ( sub, f[n & 1][i] );

	printf ( "%d\n", ( ans - sub + MOD ) % MOD );

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define rep(i,s,t) for (int i=s;i<=t;++i)

typedef long long ll;

const int mod=1e9+7;

const int maxn=1e5+10;

using namespace std;

int dp[42][(1<<17)+10];

int bit[20];

int main(){

    bit[0]=1;

    rep(i,1,19) bit[i]=bit[i-1]*2;

    int n,x,y,z;

    scanf("%d%d%d%d",&n,&x,&y,&z);

    int t=x+y+z;

    int ans=bit[x-1]+bit[x+y-1]+bit[x+y+z-1];

    dp[0][0]=1;

    rep(i,0,n-1){

        rep(j,0,bit[t]-1){

            rep(k,1,10){

                int tmp=(((j<<k)+bit[k-1])&(bit[t]-1));

                if ((tmp&ans)!=ans)(dp[i+1][tmp]+=dp[i][j])%=mod;

            }

        }

    }

    int ret=1;

    rep(i,1,n) ret=ret*10ll%mod;

    rep(i,0,bit[t]-1) ret=(ret-dp[n][i]+mod)%mod;

    printf("%d\n",ret);

}


// Faster C++ solution for the same problem (measured speedup: 1.9172955572744934x):
#include <bits/stdc++.h>

using namespace std;



#define Int register int

#define mod 1000000007



template <typename T> inline void read (T &t){t = 0;char c = getchar();int f = 1;while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}while (c >= '0' && c <= '9'){t = (t << 3) + (t << 1) + c - '0';c = getchar();} t *= f;}

template <typename T,typename ... Args> inline void read (T &t,Args&... args){read (t);read (args...);}

template <typename T> inline void write (T x){if (x < 0){x = -x;putchar ('-');}if (x > 9) write (x / 10);putchar (x % 10 + '0');}



int N,X,Y,Z,dp[41][1 << 17];



int mul (int a,int b){return 1ll * a * b % mod;}

int dec (int a,int b){return a >= b ? a - b : a + mod - b;}

int add (int a,int b){return a + b >= mod ? a + b - mod : a + b;}

void Add (int &a,int b){a = add (a,b);}

int qkpow (int a,int b){

	int res = 1;for (;b;b >>= 1,a = mul (a,a)) if (b & 1) res = mul (res,a);

	return res;

}



signed main(){

	read (N,X,Y,Z),dp[0][0] = 1;

	int ans = 1,up = (1 << X + Y + Z) - 1,st = (1 << X + Y + Z - 1) | (1 << Y + Z - 1) | (1 << Z - 1);

	for (Int i = 1;i <= N;++ i){

		ans = 1ll * ans * 10 % mod;

		for (Int S = 0;S <= up;++ S)

			if (dp[i - 1][S] && (S & st) != st)//(S&st)!=st：如果前面还没有出现过合法解 

				for (Int c = 1;c <= 10;++ c)

					Add (dp[i][((S << c) | (1 << c - 1)) & up],dp[i - 1][S]); 

	}

	for (Int S = 0;S < (1 << X + Y + Z);++ S) if ((S & st) != st) ans = dec (ans,dp[N][S]);

	write (ans),putchar ('\n');

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

using namespace std;

const ll N=42, Max=(1<<17)+10, MOD=1e9+7;

ll n, x, y, z, f[N][Max], sum=1, ans;

inline ll M(ll a){return a%MOD;}



void work(){

	for(int i = 0; i < n; i++) sum = M(sum*10);

	ll cnt = (1<<x+y+z) -1;

	ll tot = (1<<x-1) | (1<<x+y-1) | (1<<x+y+z-1); 

	f[0][0] = 1;

	for(int i = 1; i <= n; i++) 

		for(int j = 0; j <= cnt; j++) 

			for(int h = 1;h <= 10; h++){

				ans = (j<<h)|(1<<h-1);

				ans &= cnt;

				if((ans&tot)!=tot) f[i][ans] = M(f[i][ans]+f[i-1][j]);

			}

	for(int i = 0; i <= cnt; i++)

		sum = M(sum-f[n][i]+MOD);

}



int main(){

	scanf("%lld%lld%lld%lld",&n,&x,&y,&z);

	work();

	printf("%lld",sum);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.2183440065141817x):
#include <bits/stdc++.h>

using namespace std;



#define Int register int

#define mod 1000000007



template <typename T> inline void read (T &t){t = 0;char c = getchar();int f = 1;while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}while (c >= '0' && c <= '9'){t = (t << 3) + (t << 1) + c - '0';c = getchar();} t *= f;}

template <typename T,typename ... Args> inline void read (T &t,Args&... args){read (t);read (args...);}

template <typename T> inline void write (T x){if (x < 0){x = -x;putchar ('-');}if (x > 9) write (x / 10);putchar (x % 10 + '0');}



int N,X,Y,Z,dp[41][1 << 17];



int mul (int a,int b){return 1ll * a * b % mod;}

int dec (int a,int b){return a >= b ? a - b : a + mod - b;}

int add (int a,int b){return a + b >= mod ? a + b - mod : a + b;}

void Add (int &a,int b){a = add (a,b);}

int qkpow (int a,int b){

	int res = 1;for (;b;b >>= 1,a = mul (a,a)) if (b & 1) res = mul (res,a);

	return res;

}



signed main(){

	read (N,X,Y,Z),dp[0][0] = 1;

	int ans = 1,up = (1 << X + Y + Z) - 1,st = (1 << X + Y + Z - 1) | (1 << Y + Z - 1) | (1 << Z - 1);

	for (Int i = 1;i <= N;++ i){

		ans = 1ll * ans * 10 % mod;

		for (Int S = 0;S <= up;++ S)

			if (dp[i - 1][S] && (S & st) != st)//(S&st)!=st：如果前面还没有出现过合法解 

				for (Int c = 1;c <= 10;++ c)

					Add (dp[i][((S << c) | (1 << c - 1)) & up],dp[i - 1][S]); 

	}

	for (Int S = 0;S < (1 << X + Y + Z);++ S) if ((S & st) != st) ans = dec (ans,dp[N][S]);

	write (ans),putchar ('\n');

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;



const int mod = 1e9 + 7;



int n, x, y, z;

int f[50][1 << 17], ans = 1;



int main()

{

    cin >> n >> x >> y >> z;

    for (int i = 1; i <= n; i++) ans = 1ll * ans * 10 % mod;



    int tmp = (1 << x - 1) | (1 << x + y - 1) | (1 << x + y + z - 1);



    int  s = (1 << x + y + z) - 1;



    f[0][0] = 1;

    for (int i = 1; i <= n; i++)

    {

        for (int j = 0; j <= s; j++)

        {

            for (int k = 1; k <= 10; k++)

            {

                int t = (j << k) | (1 << k - 1);

                t &= s;

                if ((t & tmp) != tmp)  f[i][t] = (f[i][t] + f[i - 1][j]) % mod;

            }

        }

    }

    

    for (int i = 0; i <= s; i++)

    {

        ans = (ans - f[n][i] + mod) % mod;

    }

    printf("%d\n", ans);

}

// Faster C++ solution for the same problem (measured speedup: 2.0293739185845117x):
#include <bits/stdc++.h>

using namespace std;



#define Int register int

#define mod 1000000007



template <typename T> inline void read (T &t){t = 0;char c = getchar();int f = 1;while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}while (c >= '0' && c <= '9'){t = (t << 3) + (t << 1) + c - '0';c = getchar();} t *= f;}

template <typename T,typename ... Args> inline void read (T &t,Args&... args){read (t);read (args...);}

template <typename T> inline void write (T x){if (x < 0){x = -x;putchar ('-');}if (x > 9) write (x / 10);putchar (x % 10 + '0');}



int N,X,Y,Z,dp[41][1 << 17];



int mul (int a,int b){return 1ll * a * b % mod;}

int dec (int a,int b){return a >= b ? a - b : a + mod - b;}

int add (int a,int b){return a + b >= mod ? a + b - mod : a + b;}

void Add (int &a,int b){a = add (a,b);}

int qkpow (int a,int b){

	int res = 1;for (;b;b >>= 1,a = mul (a,a)) if (b & 1) res = mul (res,a);

	return res;

}



signed main(){

	read (N,X,Y,Z),dp[0][0] = 1;

	int ans = 1,up = (1 << X + Y + Z) - 1,st = (1 << X + Y + Z - 1) | (1 << Y + Z - 1) | (1 << Z - 1);

	for (Int i = 1;i <= N;++ i){

		ans = 1ll * ans * 10 % mod;

		for (Int S = 0;S <= up;++ S)

			if (dp[i - 1][S] && (S & st) != st)//(S&st)!=st：如果前面还没有出现过合法解 

				for (Int c = 1;c <= 10;++ c)

					Add (dp[i][((S << c) | (1 << c - 1)) & up],dp[i - 1][S]); 

	}

	for (Int S = 0;S < (1 << X + Y + Z);++ S) if ((S & st) != st) ans = dec (ans,dp[N][S]);

	write (ans),putchar ('\n');

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

 using namespace std;

 int m=1000000007,n,x,y,z;

 unsigned long long f[41][131075],ne[131075][11],i,j,k;

 int main()

{

	scanf("%d%d%d%d",&n,&x,&y,&z);

	y+=x; z+=y;

	for(i=1;i<=1<<z;i++)

	 for(j=1;j<=10;j++)

	  {

		ne[i][j]=1;

		for(k=0;k+j<=z;k++)if(i&(1<<k))

		 if(!(k<x&&k+j>x)&&!(k<y&&k+j>y))ne[i][j]|=1<<(j+k);

		if((i==(1<<z))||ne[i][j]>=1<<z)ne[i][j]=1<<z;

	  }

	f[0][1]=1;

	for(i=1;i<=n;i++)

	 for(j=1;j<=1<<z;j++)

	  for(k=1;k<=10;k++)

	   f[i][ne[j][k]]=(f[i][ne[j][k]]+f[i-1][j])%m;

	cout<<f[n][1<<z];

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8332895682336758x):
#include<cstdio>

#include<cstring>

using namespace std;

const int mo=1e9+7,MAXN=42,MAXS=1<<17|1;

int n,x,y,z;

int f[MAXN][MAXS],g[MAXS][11];

inline void add(int &x,const int &y)

{

	x+=y;

	x>=mo? x-=mo:0;

}

int main()

{

	scanf("%d%d%d%d",&n,&x,&y,&z);

	y+=x,z+=y;

	int s=1<<z;

	for(int i=1;i<=s;i++)

		for(int j=1;j<=10;j++)

		{

			g[i][j]=1;

			if(i==s)

				g[i][j]=s;

			else

			{

				for(int k=0;k<z;k++)

					if((i>>k&1)&&k+j<=z&&!(k<x&&k+j>x)&&!(k<y&&k+j>y))

						g[i][j]|=1<<k+j;

				if(g[i][j]>=s)

					g[i][j]=s;

			}

		}

	f[0][1]=1;

	for(int i=0;i<n;i++)

		for(int j=1;j<=s;j++)

			if(f[i][j])

				for(int k=1;k<=10;k++)

					add(f[i+1][g[j][k]],f[i][j]);

	printf("%d",f[n][s]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

 using namespace std;

 int m=1000000007,n,x,y,z;

 unsigned long long f[41][131075],ne[131075][11],i,j,k;

 int main()

{

	scanf("%d%d%d%d",&n,&x,&y,&z);

	y+=x; z+=y;

	for(i=1;i<=1<<z;i++)

	 for(j=1;j<=10;j++)

	  {

		ne[i][j]=1;

		for(k=0;k+j<=z;k++)if(i&(1<<k))

		 if(!(k<x&&k+j>x)&&!(k<y&&k+j>y))ne[i][j]|=1<<(j+k);

		if((i==(1<<z))||ne[i][j]>=1<<z)ne[i][j]=1<<z;

	  }

	f[0][1]=1;

	for(i=1;i<=n;i++)

	 for(j=1;j<=1<<z;j++)

	  for(k=1;k<=10;k++)

	   f[i][ne[j][k]]=(f[i][ne[j][k]]+f[i-1][j])%m;

	cout<<f[n][1<<z];

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.286805908010747x):
// Author: 23forever

#include <bits/stdc++.h>

//#define debug

const int MAXN = 40;

const int N = 5 + 7 + 5;

const int P = 1e9 + 7;

using namespace std;



inline void read(int &x) {

  x = 0; char c = getchar();

  while (!isdigit(c)) c = getchar();

  while (isdigit(c)) {

    x = (x << 1) + (x << 3) + (c ^ 48);

    c = getchar();

  }

}



int n, x, y, z;

int dp[MAXN + 5][1 << N];

int banned, S;



void print(int x) {

  bitset < 20 > tmp(x);

  cout << tmp << endl;

}



void init() {

  read(n), read(x), read(y), read(z);

  //cout << (1 << 5 - 1) << endl;

  banned = (1 << x + y + z - 1) | (1 << y + z - 1) | (1 << z - 1); 

  S = (1 << x + y + z) - 1;

  //print(S);

}



int main() {

#ifdef forever23

  freopen("test.in", "r", stdin);

  freopen("test.out", "w", stdout);

#endif

  init();



  int ans = 1; dp[0][0] = 1; 

  for (int i = 1; i <= n; ++i) {

    for (int s = 0; s <= S; ++s) {

      for (int j = 1; j <= 10; ++j) {

        int nxt_state = ((1 << j - 1) | (s << j)) & S;

        /*print(s); printf("%d\n", j);

        print(nxt_state);

        puts("");*/   

        if ((nxt_state & banned) != banned) {

          dp[i][nxt_state] = (dp[i][nxt_state] + dp[i - 1][s]) % P;

        }

      }

    }

    ans = 1LL * ans * 10 % P;

  }

  

  for (int s = 0; s <= S; ++s) {

    ans = (ans - dp[n][s] + P) % P;

  }

  printf("%d\n", ans);  

  return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

unsigned long long f[50][140000],a[140000][15];

int main(){

    int n,x,y,z;

    cin>>n>>x>>y>>z;

    y+=x;z+=y;

    int i,j,k;

    for(i=1;i<=1<<z;i++)

    for(j=1;j<=10;j++){

        a[i][j]=1;

        for(k=0;k+j<=z;k++)if(i&(1<<k))

        if(!(k<x&&k+j>x)&&!(k<y&&k+j>y))

        a[i][j]|=1<<(j+k);

        if((i==(1<<z))||a[i][j]>=1<<z)a[i][j]=1<<z;

    }

    f[0][1]=1;

    for(i=1;i<=n;i++)

    for(j=1;j<=1<<z;j++)

    for(k=1;k<=10;k++)

    f[i][a[j][k]]=(f[i][a[j][k]]+f[i-1][j])%(1000000007);

    cout<<f[n][1<<z]<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3306354977918786x):
// Author: 23forever

#include <bits/stdc++.h>

//#define debug

const int MAXN = 40;

const int N = 5 + 7 + 5;

const int P = 1e9 + 7;

using namespace std;



inline void read(int &x) {

  x = 0; char c = getchar();

  while (!isdigit(c)) c = getchar();

  while (isdigit(c)) {

    x = (x << 1) + (x << 3) + (c ^ 48);

    c = getchar();

  }

}



int n, x, y, z;

int dp[MAXN + 5][1 << N];

int banned, S;



void print(int x) {

  bitset < 20 > tmp(x);

  cout << tmp << endl;

}



void init() {

  read(n), read(x), read(y), read(z);

  //cout << (1 << 5 - 1) << endl;

  banned = (1 << x + y + z - 1) | (1 << y + z - 1) | (1 << z - 1); 

  S = (1 << x + y + z) - 1;

  //print(S);

}



int main() {

#ifdef forever23

  freopen("test.in", "r", stdin);

  freopen("test.out", "w", stdout);

#endif

  init();



  int ans = 1; dp[0][0] = 1; 

  for (int i = 1; i <= n; ++i) {

    for (int s = 0; s <= S; ++s) {

      for (int j = 1; j <= 10; ++j) {

        int nxt_state = ((1 << j - 1) | (s << j)) & S;

        /*print(s); printf("%d\n", j);

        print(nxt_state);

        puts("");*/   

        if ((nxt_state & banned) != banned) {

          dp[i][nxt_state] = (dp[i][nxt_state] + dp[i - 1][s]) % P;

        }

      }

    }

    ans = 1LL * ans * 10 % P;

  }

  

  for (int s = 0; s <= S; ++s) {

    ans = (ans - dp[n][s] + P) % P;

  }

  printf("%d\n", ans);  

  return 0;

}