#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second

#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 55, LG = 17, MOD = 1e9+7;
const int SQ = 320;
const long double EPS = 1e-7;
int cnt = 0;
vector<string> store[11];
void bt(string s = "", int sum = 0){
  if(sum > 7)return;
  store[sum].pb(s);
  f(i,0,7){
    s.pb('0' + i);
    bt(s,sum+i+1);
    s.pop_back();
  }
}
const int M = 10;
int trie[N*N*N][M];
int go[N*N*N][M];
int mrk[N*N*N], f[N*N*N];
int ptr = 1;
void BFS(){

  queue<int> q;
	for(int i = 0; i < M; i++)
		if(trie[0][i])
			q.push(trie[0][i]), f[trie[0][i]] = 0;
	for(int i = 0; i < M; i++) go[0][i] = trie[0][i];
	while(!q.empty()) {
		int x = q.front(); q.pop();
		for(int i = 0; i < M; i++) {
			if(trie[x][i]) {
				int y = trie[x][i];
				f[y] = f[x];
				while(f[y] && !trie[f[y]][i])
					f[y] = f[f[y]];
				if(trie[f[y]][i]) f[y] = trie[f[y]][i];
				q.push(y);
			}
			if(trie[x][i]) go[x][i] = trie[x][i];
			else go[x][i] = go[f[x]][i];
		}
	}

}
void ins(string x){
  int cur = 0;
  for(int i = 0; i < x.size(); i++){
      if(!trie[cur][x[i]-'0'])
        trie[cur][x[i]-'0'] = ptr++;
      cur = trie[cur][x[i]-'0'];
  }
  mrk[cur] = true;
}
int dp[N][N*N*N][2];
int n, x, y, z;
int solve(int idx, int state, bool f){
  f|=mrk[state];
  if(idx == n)
    return f;
  int &ret = dp[idx][state][f];
  if(~ret)
    return ret;
  ret = 0;
  f(j,0,10){
    ret += solve(idx+1,go[state][j], f);
    if(ret>=MOD)ret-=MOD;
  }
  return ret;
}
int32_t main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#endif // ONLINE_JUDGE



  bt();

  cin >> n >> x >> y >> z;

  for(auto X : store[x])
    for(auto Y : store[y])
      for(auto Z : store[z])if(X.size()+Y.size()+Z.size()<=n)
        ins(X+Y+Z);
  BFS();
  memset(dp,-1,sizeof dp);
  cout << solve(0,0,0) << '\n';

  return 0;
}

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
constexpr int MOD = 1e9 + 7;

template <typename T>
T mypow(T a, T b)
{
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

int n, x, y, z;

// v が x y z となっているか
bool check(const vector<int> &v)
{
    int sz = v.size();
    if (sz < 3)
        return false;
    vector<int> sum(sz + 1, 0);
    for (int i = 0; i < sz; i++)
    {
        sum[i + 1] = sum[i] + v[i];
    }
    bool f = false;
    for (int k = 0; k <= sz - 3; k++)
    {
        for (int i = k + 1; i <= sz - 2; i++)
        {
            for (int j = i + 1; j <= sz - 1; j++)
            {
                if (sum[i] - sum[k] == x && sum[j] - sum[i] == y && sum[sz] - sum[j] == z)
                    f = true;
            }
        }
    }
    return f;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> x >> y >> z;
    int sum = x + y + z;
    // dp[i][j] := i 番目迄見て, 直近(の符号)が j であり, 575 を含まないものの数
    vector<vector<ll>> dp(n + 1, vector<ll>(1 << sum, 0));
    // valid[i][j] := 直近が i の時に j を置けるか
    vector<vector<int>> valid(1 << sum, vector<int>(11, 0));
    for (int i = 0; i < (1 << sum); i++)
    {
        vector<int> num;
        int v = 0;
        for (int j = sum - 1; j >= 0; j--)
        {
            if ((i >> j) & 1)
            {
                if (v)
                    num.push_back(v);
                v = 1;
            }
            else
            {
                if (v)
                    v++;
            }
        }
        if (v)
            num.push_back(v);
        for (int j = 1; j <= 10; j++)
        {
            vector<int> num2 = num;
            num2.emplace_back(j);
            valid[i][j] = !check(num2);
        }
    }
    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < (1 << sum); j++)
        {
            for (int k = 1; k <= 10; k++)
            {
                if (!valid[j][k])
                    continue;
                int mask = ((((j << k) & ((1 << sum) - 1)) | (1 << (k - 1)))) & ((1 << sum) - 1);
                dp[i + 1][mask] += dp[i][j];
                dp[i + 1][mask] %= MOD;
            }
        }
    }
    ll ret = 0;
    for (int i = 0; i < (1 << sum); i++)
        ret = (ret + dp[n][i]) % MOD;
    cout << (mypow((ll)10, (ll)n) + MOD - ret) % MOD << endl;
}
