//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

struct Mod {
    static ll BASE;
    ll value = 0;
    static ll residue(ll value) { return (value % BASE + BASE) % BASE; }
    Mod() : Mod(0) {}
    Mod(ll value)
    : value(residue(value)) {}
    Mod operator+(const Mod& rhs) const { return Mod(value + rhs.value); }
    void operator+=(const Mod& rhs) { *this = *this + rhs; }
    Mod operator-(const Mod& rhs) const { return Mod(value - rhs.value); }
    void operator-=(const Mod& rhs) { *this = *this - rhs; }
    Mod operator*(const Mod& rhs) const { return Mod(value * rhs.value); }
    void operator*=(const Mod& rhs) { *this = *this * rhs; }
    static Mod power(Mod base, ll n) {
        assert(n >= 0);
        Mod ans(1);
        Mod pow(base);
        for (int i = 0; i < 63; i++) {
            if ((n >> i) & 1) {
                ans *= pow;
            }
            pow = pow * pow;
        }
        return ans;
    }
};
ll Mod::BASE = 1000000007;

unordered_set<string> divisions(ll X) {
    if (X == 0) {
        return {string()};
    }
    unordered_set<string> ret;
    for (ll d = 1; d <= min(X, (ll)10); d++) {
        char c = d;
        unordered_set<string> after = divisions(X - d);
        for (const string& a : after) {
            ret.insert(a + string(&c, 1));
        }
    }
    return ret;
}

int main() {
    ll N, X, Y, Z;
    cin >> N >> X >> Y >> Z;
    unordered_set<string> div_X = divisions(X);
    unordered_set<string> div_Y = divisions(Y);
    unordered_set<string> div_Z = divisions(Z);
    unordered_set<string> patterns;
    for (const string& x : div_X) {
        for (const string& y : div_Y) {
            for (const string& z : div_Z) {
                patterns.insert(x + y + z);
            }
        }
    }
    unordered_map<string, ll> state_to_id;
    unordered_map<ll, string> id_to_state;
    ll state_cnt = 0;
    state_to_id[""] = state_cnt;
    id_to_state[state_cnt] = "";
    state_cnt++;
    for (const string& pattern : patterns) {
        for (ll n = 0; n < pattern.size(); n++) {
            if (state_to_id.find(pattern.substr(0, n)) == state_to_id.end()) {
                state_to_id[pattern.substr(0, n)] = state_cnt;
                id_to_state[state_cnt] = pattern.substr(0, n);
                state_cnt++;
            }
        }
    }
    unordered_map<ll, unordered_map<char, ll>> transit;
    for (ll state_id = 0; state_id < state_cnt; state_id++) {
        string state = id_to_state[state_id];
        for (char c = 1; c <= 10; c++) {
            string next = state + string(&c, 1);
            for (ll i = 0; i <= next.size(); i++) {
                if (state_to_id.find(next.substr(i)) != state_to_id.end()) {
                    transit[state_id][c] = state_to_id.find(next.substr(i))->second;
                    break;
                }
                if (patterns.find(next.substr(i)) != patterns.end()) {
                    transit[state_id][c] = -1;
                    break;
                }
            }
        }
    }
    for (char c = 1; c <= 10; c++) {
        transit[-1][c] = -1;
    }
    vector<unordered_map<ll, Mod>> dp(N+1);
    dp[0][0] = 1;
    for (ll n = 0; n < N; n++) {
        for (const auto& kv : dp[n]) {
            for (char c = 1; c <= 10; c++) {
                dp[n+1][transit[kv.first][c]] += dp[n][kv.first];
            }
        }
    }
    Mod comp;
    for (const auto& kv : dp[N]) {
        if (kv.first != -1) {
            comp += kv.second;
        }
    }
    Mod ans = Mod::power(10, N) - comp;
    cout << ans.value << endl;
}

Measured memory_bytes: 48128