#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;



template<lint mod>
struct Int_{
  unsigned x;
  unsigned mpow(Int_ a,unsigned k){
    Int_ res=1;
    while(k){
      if(k&1) res=res*a;
      a=a*a;
      k>>=1;
    }
    return res.x;
  }
  unsigned inverse(Int_ a){
    return mpow(a,mod-2);
  }
  Int_(): x(0) { }
  Int_(long long sig) {
    int sigt=sig%mod;
    if(sigt<0) sigt+=mod;
    x=sigt;
  }
  unsigned get() const { return (unsigned)x; }
  
  Int_ &operator+=(Int_ that) { if((x += that.x) >= mod) x -= mod; return *this; }
  Int_ &operator-=(Int_ that) { if((x += mod - that.x) >= mod) x -= mod; return *this; }
  Int_ &operator*=(Int_ that) { x = (unsigned long long)x * that.x % mod; return *this; }
  Int_ &operator=(Int_ that) { x=that.x; return *this;}
  Int_ &operator/=(Int_ that) { x=(unsigned long long) x * inverse(that.x)%mod; return *this;}
  bool operator==(Int_ that) const { return x==that.x; }
  bool operator!=(Int_ that) const { return x!=that.x; }

  Int_ operator-() const { return Int_(0)-Int_(*this);}
  Int_ operator+(Int_ that) const { return Int_(*this) += that; }
  Int_ operator-(Int_ that) const { return Int_(*this) -= that; }
  Int_ operator*(Int_ that) const { return Int_(*this) *= that; }
  Int_ operator/(Int_ that) const { return Int_(*this) /= that; }

};

namespace std{
  template<lint mod>
  ostream &operator <<(ostream& out,const Int_<mod>& a){
    out<<a.get();
    return out;
  }
  template<lint mod>
  istream &operator >>(istream& in,Int_<mod>& a){
    in>>a.x;
    return in;
  }
};

typedef Int_<1000000007> Int;

int n,x,y,z;
Int pw10[45];

typedef vector<int> vi;
typedef pair<vi,vi> pv;
map<pv,Int> dp[45];

int main(){
  pw10[0]=1;
  REP(i,44) pw10[i+1]=pw10[i]*10;

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

  dp[0][mp(vi(0),vi(1,0))]=1;

  Int res=0;
  REP(i,n) for(auto e:dp[i]){
    vi prev=e.fr.fr,able=e.fr.sc;

    Int val=e.sc;
    for(int j=1;j<=10;++j){
      vi nxt=e.fr.fr,nable=able;

      int nstate=0;
      int sum=j;
      int m=able.size();
      bool ok=false;
      REP(k,m){
        if(sum==x) nstate|=1;
        if(sum==y && able[m-1-k]&1) nstate|=2;
        if(sum==z && able[m-1-k]&2) ok=true;
        if(k<m-1) sum+=prev[m-2-k];
      }
      if(ok){
        res+=pw10[n-i-1]*val;
        continue;
      }
      nxt.pb(j);
      nable.pb(nstate);
      while(accumulate(ALL(nxt),0)>=7){
        nxt.erase(nxt.begin());
        nable.erase(nable.begin());
      }
      dp[i+1][mp(nxt,nable)]+=val;
    }
  }
  cout<<res<<endl;
  return 0;
}




Measured memory_bytes: 19328