#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;
 
int N, X, Y, Z;
 
i64 dp[41][1 << 17];
const int mask = (1 << 17) - 1;
 
int trans[1 << 17][11];
i64 powten[41];
 
int main()
{
    scanf("%d%d%d%d", &N, &X, &Y, &Z);
 
    dp[0][1] = 1;
 
    powten[0] = 1;
    for (int i = 0; i < N; ++i) {
        powten[i + 1] = powten[i] * 10 % MOD;
    }

    //for (int j = 1; j <= 10; ++j) {
    //    cout << "j: " << j << endl;
    //    for (int k = 0; k < 17; ++k) {
    //        if (k < X && X < k + j) {
    //            //i2 &= ~(1 << k); // turn k'th element to 0
    //            cout << k << " ";
    //        }
    //    }
    //    cout << " / ";
    //    for (int k = 0; k < 17; ++k) {
    //        if (k < X + Y && X + Y < k + j) {
    //            //i2 &= ~(1 << k);
    //            cout << k << " ";
    //        }
    //    }
    //    cout << " / ";
    //    for (int k = 0; k < 17; ++k) {
    //        if (k < X + Y + Z && X + Y + Z < k + j) {
    //            //i2 &= ~(1 << k);
    //            cout << k << " ";
    //        }
    //    }
    //    cout << endl;
    //}
    //cout << endl;


    for (int i = 0; i < (1 << 17); ++i) {
        for (int j = 1; j <= 10; ++j) {
            int i2 = i;

            //int b = 0b00000000000000000000000000000001;
            //int b = 0b00000000000000000000000000010000;
            //if (i == b) {
            //    cout << "j: " << j << endl;
            //    cout << bitset<32>(i) << endl;
            //}

            for (int k = 0; k < 17; ++k) {
                //if (k < X && X < k + j) {
                //    i2 &= ~(1 << k); // turn k'th element to 0
                //}
                //if (k < X + Y && X + Y < k + j) {
                //    i2 &= ~(1 << k);
                //}
                //if (k < X + Y + Z && X + Y + Z < k + j) {
                //    i2 &= ~(1 << k);
                //}

                //if (k < X && X < k + j) i2 &= ~(1 << k); // turn k'th element to 0
                //if (k < X + Y && X + Y < k + j) i2 &= ~(1 << k);
                //if (k < X + Y + Z && X + Y + Z < k + j) i2 &= ~(1 << k);

                //if (k < X && k + j > X) i2 &= ~(1 << k);
                //if (k < X + Y && k + j > X + Y) i2 &= ~(1 << k);
                //if (k < X + Y + Z && k + j > X + Y + Z) i2 &= ~(1 << k);
            }

            //if (i == b) {
            //    cout << bitset<32>(i2) << endl;
            //}

            i2 <<= j; // shift 1
            i2 |= 1;  // turn 0th element to 1
            i2 &= (1 << 18) - 1;

            //if (i == b) {
            //    cout << bitset<32>(i2) << endl;
            //    cout << endl;
            //}
 
            trans[i][j] = i2;

            //cout << "i: " << bitset<32>(i) << ", i2: " << bitset<32>(i2) << ", j: " << j << endl;
        }
    }
 
    i64 ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < (1 << 17); ++j) {
            for (int k = 1; k <= 10; ++k) {
                int j2 = trans[j][k];
 
                //if (j2 & (1 << (X + Y + Z))) {
                if (
                    j2 & (1 << (X + Y + Z)) &&
                    j2 & (1 << (Y + Z)) &&
                    j2 & (1 << (Z)) 
                    ) {
                    //if (dp[i][j] * powten[N-i-1] > 0) {
                    //    cout << bitset<32>(j) << " " << k << " " << bitset<32>(j2) << " " << dp[i][j] * powten[N-i-1] << endl;
                    //}
                    ADD(ans, dp[i][j] * powten[N - i - 1] % MOD); // 10^(N-i-1)
                    continue;
                }

                j2 &= mask;
                ADD(dp[i + 1][j2], dp[i][j]);
            }
        }
    }

    // (X + Y + Z) == 3 -> ???1??1
    // (X + Y + Z) == 4 -> ??1???1

    //int b = 0b00000000000000000000000000000111;
    //cout << bitset<32>(b) << " " << bitset<32>(trans[b][1]) << " " << 1 << endl;
    //cout << bitset<32>(b) << " " << bitset<32>(trans[b][2]) << " " << 2 << endl;
    //cout << bitset<32>(b) << " " << bitset<32>(trans[b][3]) << " " << 3 << endl;
    //cout << bitset<32>(b) << " " << bitset<32>(trans[b][4]) << " " << 4 << endl;
    //cout << bitset<32>(b) << " " << bitset<32>(trans[b][5]) << " " << 5 << endl;
    //cout << bitset<32>(b) << " " << bitset<32>(trans[b][6]) << " " << 6 << endl;
    //cout << bitset<32>(b) << " " << bitset<32>(trans[b][7]) << " " << 7 << endl;
    //cout << bitset<32>(b) << " " << bitset<32>(trans[b][8]) << " " << 8 << endl;
    //cout << bitset<32>(b) << " " << bitset<32>(trans[b][9]) << " " << 9 << endl;

    //ans = 0;
    //for (int i = 0; i < (1 << 17); ++i) {
    //    ans += dp[3][i];
    //}

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 46848