#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = (int)1e9 + 7;

int mult(int a, int b) {
    return (1LL * a * b) % mod;
}

int pw(int a, int b) {
    if (b == 0) return 1;
    if (b & 1) return mult(a, pw(a, b - 1));
    int res = pw(a, b / 2);
    return mult(res, res);
}

int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}

int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}

const int maxN = 45;
map < vector < int >, int > mp[maxN];
map < vector < int >, vector < int > > trans;
int n, x, y, z;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
   // freopen("input.txt", "r", stdin);
    cin >> n >> x >> y >> z;
    int all = pw(10, n);
    mp[0][{}] = 1;
    for (int i = 0; i < n; i++) {
        for (auto& it : mp[i]) {
            vector < int > gg = it.first;
            for (int dig = 1; dig <= 10; dig++) {
                if (dig >= 8) {
                    mp[i + 1][{}] = sum(mp[i + 1][{}], it.second);
                    continue;
                }
                vector < int > ng = gg;
                ng.push_back(dig);
                if (trans.find(ng) != trans.end()) {
                    ng = trans[ng];
                }
                else {
                    vector < int > cp = ng;
                    bool ok = true;
                    while (true) {
                        int ind = 0;
                        int sum = 0;
                        while (ind < ng.size() && sum < x) {
                            sum += ng[ind];
                            ind++;
                        }
                        if (sum > x) {
                            ng.erase(ng.begin());
                            continue;
                        }
                        if (sum == x) {
                            sum = 0;
                            while (ind < ng.size() && sum < y) {
                                sum += ng[ind];
                                ind++;
                            }
                            if (sum > y) {
                                ng.erase(ng.begin());
                                continue;
                            }
                            if (sum == y) {
                                sum = 0;
                                while (ind < ng.size() && sum < z) {
                                    sum += ng[ind];
                                    ind++;
                                }
                                if (sum > z) {
                                    ng.erase(ng.begin());
                                    continue;
                                }
                                if (sum == z) {
                                    ok = false;
                                    break;
                                }
                                else break;
                            }
                            else break;
                        }
                        else break;
                    }
                    if (!ok) {
                        trans[cp] = {-1};
                        ng = {-1};
                    }
                    else {
                        trans[cp] = ng;
                    }
                }
                if (!ng.empty() && ng.back() == -1) continue;
                mp[i + 1][ng] = sum(mp[i + 1][ng], it.second);
            }
        }
    }
    int ans = 0;
    for (auto& it : mp[n]) {
        ans = sum(ans, it.second);
    }
    cout << sub(all, ans);
    return 0;
}

Measured memory_bytes: 92416