#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

int m = 1000000007;
long long a[41];
int b[100000][10];
int dp[41][100000];
map <vector <int>, int> mp;

int main() {
    int n, x, y, z, c = 0, i, j, k;
    long long ans = 0;
    queue <vector <int> > q;
    
    scanf("%d %d %d %d", &n, &x, &y, &z);
    
    a[0] = 1;
    for (i = 1; i <= 40; i++) a[i] = a[i - 1] * 10 % m;
    
    mp[vector <int>()] = c++;
    q.push(vector <int>());
    
    while (!q.empty()) {
        int sum = 0, f = 0, p;
        vector <int> v = q.front();
        
        q.pop();
        
        p = mp[v];
        
        for (i = 0; i < v.size(); i++) {
            sum += v[i];
            
            if (f == 0 && sum == x) {
                f = 1;
            } else if (f == 1 && sum == x + y) {
                f = 2;
            }
        }
        
        for (i = 1; i <= 10; i++) {
            if (f == 2 && sum + i == x + y + z) {
                b[p][i - 1] = -1;
            } else if ((f == 0 && sum + i <= x) || (f == 1 && sum + i <= x + y) || (f == 2 && sum + i <= x + y + z)) {
                vector <int> w = v;
                
                w.push_back(i);
                
                b[p][i - 1] = c;
                mp[w] = c++;
                q.push(w);
            } else {
                for (j = 1; j < v.size(); j++) {
                    int sum2 = 0, f2 = 0;
                    
                    for (k = j; k < v.size(); k++) {
                        sum2 += v[k];
                        
                        if (f2 == 0) {
                            if (sum2 > x) break;
                            
                            if (sum2 == x) f2 = 1;
                        } else if (f2 == 1) {
                            if (sum2 > x + y) break;
                            
                            if (sum2 == x + y) f2 = 2;
                        }
                    }
                    
                    if (k == v.size()) {
                        if (f2 == 2 && sum2 + i == x + y + z) {
                            b[p][i - 1] = -1;
                            
                            break;
                        } else if ((f2 == 0 && sum2 + i <= x) || (f2 == 1 && sum2 + i <= x + y) || (f2 == 2 && sum2 + i <= x + y + z)) {
                            vector <int> w;
                            
                            for (k = j; k < v.size(); k++) w.push_back(v[k]);
                            w.push_back(i);
                            
                            if (mp.count(w)) {
                                b[p][i - 1] = mp[w];
                            } else {
                                b[p][i - 1] = c;
                                mp[w] = c++;
                                q.push(w);
                            }
                            
                            break;
                        }
                    }
                }
                
                if (j >= v.size()) {
                    vector <int> w;
                    
                    if (i <= x) w.push_back(i);
                    
                    if (mp.count(w)) {
                        b[p][i - 1] = mp[w];
                    } else {
                        b[p][i - 1] = c;
                        mp[w] = c++;
                        q.push(w);
                    }
                }
            }
        }
    }
    
    dp[0][0] = 1;
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < c; j++) {
            if (dp[i][j] == 0) continue;
            
            for (k = 0; k < 10; k++) {
                if (b[j][k] == -1) {
                    ans += dp[i][j] * a[n - i - 1] % m;
                    if (ans >= m) ans -= m;
                } else {
                    dp[i + 1][b[j][k]] += dp[i][j];
                    if (dp[i + 1][b[j][k]] >= m) dp[i + 1][b[j][k]] -= m;
                }
            }
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 5632