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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
const int mod = 1e9+7;

int dp[45][1<<17];
int main(){
    int n, x, y, z;
    scanf("%d%d%d%d", &n, &x, &y, &z);
    int b = (1<<(x+y+z-1))|(1<<(y+z-1))|(1<<(z-1));
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<(1<<17);j++){
            if(dp[i-1][j] == 0) continue;
            for(int k=1;k<=10;k++){
                int nt = (j<<k) + (1<<(k-1));
                nt &= (1<<17)-1;
                if((nt&b) == b) continue;
                dp[i][nt] = (dp[i][nt] + dp[i-1][j])%mod;
            }
        }
    }
    ll ans = 1;
    for(int i=1;i<=n;i++) ans = ans*10%mod;
    for(int j=0;j<(1<<17);j++) ans = (ans - dp[n][j] + mod)%mod;
    printf("%lld\n", ans);
}
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int N=3e5+10,P=1e9+7;
const int tr[][2]={{1,2},{3,4},{5,6},{1,1},{1,2},{7,2},{6,6},{5,5}};
char s[N];int dp[N][8];
inline void upd(int &x,int y){((x+=y)>=P)&&(x-=P);}
int main(){
	scanf("%s",s);int n=strlen(s);
	dp[0][0]=1;
	rep(i,0,n-1){
		rep(j,0,7){
			if(s[i]^49) upd(dp[i+1][tr[j][0]],dp[i][j]);
			if(s[i]^48) upd(dp[i+1][tr[j][1]],dp[i][j]);
		}
	}
	printf("%d\n",dp[n][2]+dp[n][6]>=P?dp[n][2]+dp[n][6]-P:dp[n][2]+dp[n][6]);
	return 0;
}