
#include<iostream>
#include<vector>
using namespace std;

unsigned long long ans=0;
vector<int> a;
void rec(int sum, int odd, int even)
{
  if(odd+even==0){
    if(sum%10==0)ans++;
    return;
  }
  for(int i=0; i<a.size(); i++){
    if(odd)rec(sum+a[i], odd-1, even);
    else rec(sum+(2*a[i]/10)+((2*a[i])%10), odd, even-1);
  }
}

int main()
{
  int n,m;
  cin>>n;
  vector<char>ID(n);
  int sum=0;
  int odd=0,even=0;
  bool flagOdd=n&1;
  flagOdd^=1;
  for(int i=0; i<n; i++){
    cin>>ID[i];
    flagOdd^=1;
    if(ID[i]=='*'){
      if(flagOdd)odd++;
      else even++;
      continue;
    }
    ID[i]-='0';
    if(flagOdd)sum+=ID[i]%10;
    else sum+=(2*ID[i]/10)+((2*ID[i])%10);
  }
  cin>>m;
  a.resize(m);
  for(int i=0; i<m; i++){
    cin>>a[i];
  }
  rec(sum, odd, even);
  cout<<ans<<endl;
}