#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 1055050
ll dp[50][1<<20];
bool judge[N];
ll pw[50];
main(){
    ios_base::sync_with_stdio(false);
    int n=in();
    int x[3];
    rep(i,3)x[i]=in();
    int sum=x[0]+x[1]+x[2];
    ll ans=0;
    pw[0]=1;
    rep(i,20)pw[i+1]=pw[i]*2;
    dp[0][0]=1;
    vec all;
    rep(i,1<<sum){
        if((i&(1<<(x[2]-1))&&(i&(1<<(x[2]+x[1]-1))&&(i&1<<(sum-1)))))judge[i]=1;
        else all.pb(i);
    }
    rep(i,n){
        for(auto k:all){
            if(dp[i][k]==0)continue;
            rep2(j,1,7){
                ll next=(k*pw[j]+pw[j-1])%pw[sum];
                if(!judge[next])
                dp[i+1][next]=(dp[i][k]+dp[i+1][next])%MOD;
            }
            dp[i+1][0]=(dp[i+1][0]+dp[i][k]*3)%MOD;
        }
    }
    ll p=1;
    rep(i,n){
        p=p*10ll%MOD;
    }
    rep(i,1<<sum){
        p=(p-dp[n][i]+MOD)%MOD;
    }
    cout<<p<<endl;
}
#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

const int mod = (int) 1e9 + 7;

int n;
int x, y, z;

map <vector<int>, int> mp;
vector<int> seq[205000];
int len[205000];
int seqSum[205000];
bool haiku[205000];
int cnt;
int mxSum = 0;
int mxNum = 0;

bool check(vector<int>& v) {
    int p = 0;
    int xx = x, yy = y, zz = z;
    while (p < sz(v) && xx > 0) {
        xx -= v[p];
        p++;
    }
    while (p < sz(v) && yy > 0) {
        yy -= v[p];
        p++;
    }
    while (p < sz(v) && zz > 0) {
        zz -= v[p];
        p++;
    }
    return xx == 0 && yy == 0 && zz == 0 && p == sz(v);
}

void go(vector<int>& v, int sum) {
    mp[v] = cnt;
    len[cnt] = sz(v);
    seq[cnt] = v;
    seqSum[cnt] = sum;
    haiku[cnt] = check(v);
    cnt++;

    for (int i = 1; i <= min(mxNum, mxSum - sum); i++) {
        v.push_back(i);
        go(v, sum + i);
        v.pop_back();
    }
}

long long dp[45][2][130500];
int mv[130500][12];

int main() {

    cin >> n >> x >> y >> z;
    mxSum = x + y + z;
    mxNum = max(max(x, y), z);

    vector<int> v;
    go(v, 0);

    // cerr << cnt << endl;

    for (int i = 0; i < cnt; i++) {
        for (int num = 1; num <= mxNum; num++) {
            int sum = seqSum[i] + num;
            int p = 0;
            while (p < sz(seq[i]) && sum > mxSum) {
                sum -= seq[i][p];
                p++;
            }
            vector<int> go;
            while (p < sz(seq[i])) {
                go.push_back(seq[i][p]);
                p++;
            }
            go.push_back(num);
            mv[i][num] = mp[go];
        }
    }

    dp[0][0][0] = true;
    for (int i = 0; i < n; i++) 
        for (int j = 0; j <= 1; j++) 
            for (int k = 0; k < cnt; k++) {
                if (dp[i][j][k] == 0) continue;
                if (haiku[k] && j == 0) continue;
                if (len[k] > i) continue;

                for (int num = 1; num <= mxNum; num++) {
                    int goK = mv[k][num];
                    dp[i + 1][j | haiku[goK]][goK] = (dp[i + 1][j | haiku[goK]][goK] + dp[i][j][k]) % mod;
                }
                dp[i + 1][j][0] = (dp[i + 1][j][0] + dp[i][j][k] * (10 - mxNum)) % mod;
            }

    long long ans = 0;
    for (int i = 0; i < cnt; i++)
        ans = (ans + dp[n][1][i]) % mod;

    cout << ans << endl;

    return 0;
}
