#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;
using P3 = std::tuple<int,ll,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

const ll MOD = 1000000000ll + 7;

int N, X[3];
map<P3, ll> dp;

template <typename T>
T expt(T a, T n, T mod = std::numeric_limits<T>::max()){
    T res = 1;
    while(n){
        if(n & 1){res = res * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

tuple<int, int, int, int, int> f(int pr1, int pr2, int pr3, int last){
    int prs[3] = {pr1, pr2, pr3}, sum[3];
    deque<int> deq[3];
    
    memset(sum, 0, sizeof(sum));
    
    for(int i=0;i<3;++i){
        while(prs[i] > 0){
            int x = prs[i] & 7;
            deq[i].push_front(x);
            sum[i] += x;
            prs[i] >>= 3;
        }
    }

    deq[2].push_back(last);
    sum[2] += last;
    
    while(!deq[0].empty() || !deq[1].empty() || !deq[2].empty()){        
        for(int i=0;i<3;++i){
            if(!deq[i].empty()){
                sum[i] -= deq[i].front();
                deq[i].pop_front();
                break;
            }
        }
        
        for(int i=0;i<2;++i){
            for(int j=i+1;j<3;++j){
                while(!deq[j].empty() && sum[i] + deq[j].front() <= X[i]){
                    int x = deq[j].front();
                    sum[j] -= x;
                    sum[i] += x;
                    deq[i].push_back(x);
                    deq[j].pop_front();
                }

                if(!deq[j].empty()){break;}
            }
        }

        bool followedByEmptyDeque = true, isValid = true;
        for(int i=2;i>=0;--i){
            if((followedByEmptyDeque && sum[i] <= X[i]) ||
               (!followedByEmptyDeque && sum[i] == X[i])){
                
            }else{
                isValid = false;
                break;
            }

            if(!deq[i].empty()){
                followedByEmptyDeque = false;
            }
        }
        
        if(isValid){
            int nstate = 0, nsum = 0;

            for(int i=2;i>=0;--i){
                if(sum[i] == X[i]){++nstate;}
                else{nsum = sum[i];}
                
                while(!deq[i].empty()){
                    prs[i] = prs[i] * 8 + deq[i].front();
                    deq[i].pop_front();
                }
            }

            return std::make_tuple(prs[0], prs[1], prs[2], nsum, nstate);
        }
    }

    return std::make_tuple(0, 0, 0, 0, 0);
}

// state = 0: X[0]が拾えていない
// state = 1: X[0]が拾えた
// state = 2: X[1]が拾えた
// state = 3: X[2]が拾えた
ll rec(int idx, int pr1, int pr2, int pr3, int sum, int state){
    if(state == 3){
        return expt(10ll, 1ll * N - idx, MOD);
    }
    if(idx == N){
        return 0;
    }

    auto t = std::make_tuple(idx, 1ll * pr1 + (1ll << 15) * (1ll * pr2 + (1ll << 21) * pr3), state);
    {
        auto it = dp.find(t);
        if(it != dp.end()){
            return it->second;
        }
    }

    dp[t] = 0;
    int prs[3] = {pr1, pr2, pr3};

    for(int i=1;i<=10;++i){
        if(sum + i < X[state]){
            int nprs[3];
            copy(prs, prs + 3, nprs);
            nprs[state] = nprs[state] * 8 + i;
            dp[t] = (dp[t] + rec(idx + 1, nprs[0], nprs[1], nprs[2], sum + i, state)) % MOD;
        }else if(sum + i == X[state]){
            int nprs[3];
            copy(prs, prs + 3, nprs);
            nprs[state] = nprs[state] * 8 + i;
            dp[t] = (dp[t] + rec(idx + 1, nprs[0], nprs[1], nprs[2], 0, state + 1)) % MOD;
        }else{
            int npr1, npr2, npr3, nsum, nstate;
            tie(npr1, npr2, npr3, nsum, nstate) = f(pr1, pr2, pr3, i);

            dp[t] = (dp[t] + rec(idx + 1, npr1, npr2, npr3, nsum, nstate)) % MOD;
        }
    }

    return dp[t];
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> N;
    for(int i=0;i<3;++i){
        std::cin >> X[i];
    }

    std::cout << rec(0, 0, 0, 0, 0, 0) << std::endl;
}


Measured memory_bytes: 46080