#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;

const int MOD = 1e9 + 7;

void ModSum(int& x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
    if (x < 0) {
        x += MOD;
    }
}

void ModMul(int& x, int y) {
    x = (1LL * x * y) % MOD;
}

int GetBinaryPow(int x, int pw) {
    int r = 1;
    while (pw > 0) {
        if (pw & 1) {
            ModMul(r, x);
        }
        ModMul(x, x);
        pw >>= 1;
    }
    return r;
}

int GetInv(int x) {
    return GetBinaryPow(x, MOD - 2);
}

void FillReprs(int n, vector<int>& curRepr, vector<vector<int>>& reprs) {
    if (n == 0) {
        reprs.push_back(curRepr);
        return;
    }
    for (int x = 1; x <= n; ++x) {
        curRepr.push_back(x);
        FillReprs(n - x, curRepr, reprs);
        curRepr.pop_back();
    }
}

vector<vector<int>> GetReprs(int n) {
    vector<vector<int>> reprs;
    vector<int> curRepr;
    FillReprs(n, curRepr, reprs);
    return reprs;
}

const int MAX_NODE_COUNT = 2e5;
const int MAX_C = 10;

struct TNode {
    int Next[MAX_C];
    int SuffLink;
    int To[MAX_C];
    int IsEnd;
};

TNode nodes[MAX_NODE_COUNT];
int nodeCount;

void ClearNode(int node) {
    nodes[node].IsEnd = false;
    for (int i = 0; i < MAX_C; ++i) {
        nodes[node].Next[i] = -1;
        nodes[node].SuffLink = -1;
        nodes[node].To[i] = -1;
    }
}

void Init() {
    nodeCount = 1;
    ClearNode(0);
}

int GetNewNode() {
    ClearNode(nodeCount);
    ++nodeCount;
    return nodeCount - 1;
}

void Add(const vector<int>& vals) {
    int node = 0;
    for (int i = 0; i < (int) vals.size(); ++i) {
        int c = vals[i];

        if (nodes[node].Next[c] == -1) {
            nodes[node].Next[c] = GetNewNode();
        }

        node = nodes[node].Next[c];
    }
    nodes[node].IsEnd = true;
}

void BuildSuffLinks() {
    queue<int> q;
    q.push(0);
    nodes[0].SuffLink = -1;
    for (int c = 0; c < MAX_C; ++c) {
        if (nodes[0].Next[c] == -1) {
            nodes[0].To[c] = 0;
        } else {
            nodes[0].To[c] = nodes[0].Next[c];
        }
    }
    while (!q.empty()) {
        int node = q.front();
        q.pop();

        for (int c = 0; c < MAX_C; ++c) {
            int nxt = nodes[node].Next[c];

            if (nxt != -1) {
                q.push(nxt);

                int link = nodes[node].SuffLink;

                if (link == -1) {
                    link = 0;
                } else {
                    link = nodes[link].To[c];
                }

                nodes[nxt].SuffLink = link;

                if (nodes[node].IsEnd) {
                    nodes[nxt].IsEnd = true;
                }

                for (int nc = 0; nc < MAX_C; ++nc) {
                    if (nodes[nxt].Next[nc] != -1) {
                        nodes[nxt].To[nc] = nodes[nxt].Next[nc];
                    } else {
                        nodes[nxt].To[nc] = nodes[link].To[nc];
                    }
                }
            }
        }
    }
}

int main() {
    Init();

    int n, x, y, z;
    scanf("%d%d%d%d", &n, &x, &y, &z);

    vector<vector<int>> r1 = GetReprs(x);
    vector<vector<int>> r2 = GetReprs(y);
    vector<vector<int>> r3 = GetReprs(z);

    for (const vector<int>& t1 : r1) {
        for (const vector<int>& t2 : r2) {
            for (const vector<int>& t3 : r3) {
                vector<int> comb;
                for (int x : t1) {
                    comb.push_back(x - 1);
                }
                for (int x : t2) {
                    comb.push_back(x - 1);
                }
                for (int x : t3) {
                    comb.push_back(x - 1);
                }
                Add(comb);
            }
        }
    }

    BuildSuffLinks();

    /*
    for (int node = 0; node < nodeCount; ++node) {
        cout << node << ": " << nodes[node].SuffLink << endl;
    }
    return 0;
    */

    vector<int> pws(n + 1);
    pws[0] = 1;
    for (int i = 1; i <= n; ++i) {
        pws[i] = pws[i - 1];
        ModMul(pws[i], 10);
    }

    vector<int> dp[2];

    int curPtr = 0;
    dp[curPtr].assign(nodeCount, 0);
    dp[curPtr][0] = 1;

    int result = 0;
    for (int itr = 1; itr <= n; ++itr) {
        /*
        for (int node = 0; node < nodeCount; ++node) {
            cout << dp[curPtr][node] << " ";
        }
        cout << endl;
        */
        int nxtPtr = 1 - curPtr;
        dp[nxtPtr].assign(nodeCount, 0);

        for (int node = 0; node < nodeCount; ++node) {
            for (int nxt = 0; nxt < MAX_C; ++nxt) {
                int newNode = nodes[node].To[nxt];
                if (newNode != -1) {
                    ModSum(dp[nxtPtr][newNode], dp[curPtr][node]);
                }
            }
        }

        swap(curPtr, nxtPtr);

        for (int node = 0; node < nodeCount; ++node) {
            if (nodes[node].IsEnd) {
                int cur = dp[curPtr][node];
                ModMul(cur, pws[n - itr]);
                ModSum(result, cur);
                dp[curPtr][node] = 0;
            }
        }
    }

    printf("%d\n", result);

    return 0;
}

Measured memory_bytes: 3456