#include<bits/stdc++.h>

using namespace std;

int sir[70004][20], sz[70004], sum[70004], dp[2][70004], trie [70004][10];
int mod = 1e9 + 7, ras, n, nr, maxs, d[5], aux[50], a[70004][20];

void back (int l, int cod, int s)
{
    for (int i = 1; i <= l; i++)
        sir[cod][i] = aux[i];     /// Memorez sirul de stare in vectorul sir
    sz[cod] = l;                /// Lungimea starii
    sum[cod] = s;               /// Suma starii
    for (int i = 1; i <= 7; i++)
        if (s + i < maxs)
        {
            aux[l + 1] = i;
            trie[cod][i] = ++nr;       /// Si codurile starilor in trie
            back (l + 1, trie[cod][i], s + i);
        }
}

void creareautonom()     /// Pentru fiecare stare vad in ce stare ajung daca adaug un numar de la 1 la 10
                         /// ca si cum as face cu 2 indici.
{
    for (int stare = 0; stare <= nr; stare ++)
        for (int val = 1; val <= 10; val ++)
        {
            if (val > 7)
            {
                a[stare][val] = 0;
                continue;
            }
            sir[stare][sz[stare] + 1] = val;
            int s = sum[stare] + val, i = 1;
            while ( s > maxs && i <= sz[stare]) s -= sir[stare][i++];
            //for (i = 1; i <= sz[stare] && s > maxs; i++)s -= sir[stare][i];
            if (s == maxs)
            {
                int s1 = 0;
                int pos = 1;
                for(int j = i; j <= sz[stare] + 1; j++)
                {
                    s1 += sir[stare][j];
                    if(s1 == d[pos])
                    {
                        s1 = 0;
                        pos ++;
                    }
                }
                if (pos == 4)
                {
                    a[stare][val] = -1;
                    continue ;
                }
                i++;
            }

            int stare_noua = 0;

            for(int j = i; j <= sz[stare] + 1; j ++)
                stare_noua = trie[stare_noua][ sir[stare][j] ];
            a[stare][val] = stare_noua;
        }
}

void dinamica()   /// dp[i][stare] = numarul de siruri de lungime i care duc in stare
{
    int stare_noua;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int stare = 0; stare <= nr; stare ++)
            if (dp[(i - 1) & 1][stare] != 0)
            {
                for (int j = 1; j <= 10; j ++)
                    if ( a[stare][j] != -1)
                    {
                        stare_noua = a[stare][j];
                        dp[i & 1][stare_noua] += dp[(i - 1) & 1][stare];
                        if (dp[i & 1][stare_noua] >= mod) dp[i & 1][stare_noua] -= mod;
                    }
                dp[(i - 1) & 1][stare] = 0;
            }

    }
    ras = 1;
    for (int i = 1; i <= n; i ++)
        ras = (1LL * 10 * ras) % mod;
    for (int stare = 0; stare <= nr; stare ++)
    {
        ras -= dp[n&1][stare];
        if (ras < 0) ras += mod;
    }
    printf ("%d", ras);
}
int main()
{
    //freopen ("input", "r", stdin);
    //freopen ("output", "w", stdout);
    scanf ("%d %d %d %d", &n, &d[1], &d[2], &d[3]);
    maxs = d[1] + d[2] + d[3];
    back (0, 0, 0);
    creareautonom ();
    dinamica ();
    return 0;
}
/**/


Measured memory_bytes: 14592