#include<iostream>
#include<algorithm>
#define v(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,m,q[2]={0},s=0,a[10];
	long long dp[2][10],c[10];
	char z;
	cin>>n;
	v(i,n){
		cin>>z;
		if(z=='*')q[1-((n-i)%2)]++;
		else{
			z-='0';
			if((n-i)%2==0)z=(z*2-1)%9+1;
			s+=z;
		}
	}
	cin>>m;
	v(i,m)cin>>a[i];
	v(i,2)v(j,10)dp[i][j]=0;
	v(i,2)dp[i][0]=1;
	v(i,2){
		v(j,q[i]){
			v(k,10)c[k]=0;
			v(k,m){
				v(r,10){
					c[(r+a[k])%10]+=dp[i][r];
				}
			}
			v(k,10)dp[i][k]=c[k];
		}
		v(i,m)a[i]=(a[i]*2-1)%9+1;
	}
	long long ans=0;
	v(i,10)v(j,10)if((s+i+j)%10==0)ans+=dp[0][i]*dp[1][j];
	cout<<ans<<endl;
	return 0;
}