#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;


typedef long long LL;
const int SIZE = 10;
typedef set<int> SI;
int n;
string s;
int a_num;
int m;
int T[SIZE];
bool C[SIZE];
int d_sum;

int to_int( char c ) {
    if ( c == '*' ) return 0;
    return c - '0';
}

int get_b( bool f, int t ) {
    int nt = 2 * t;
    if ( ! f ) return t;
    return nt >= 10 ? nt/10%10 + nt%10 : nt;
}

bool input() {
    if ( ! ( cin >> n && n ) ) return false;
    cin >> s;
    a_num = count( s.begin(), s.end(), '*' );
    d_sum = 0;
    for ( int i = 0; i < n; ++ i ) {
        d_sum += get_b(i%2==1,to_int(s[n-i-1]));
    }
    for ( int i = 0, j = 0; i < n && j < a_num; ++ i ) {
        if ( s[n-i-1] == '*' ) {
            C[j++] = ( i % 2 == 1 );
        }
    }
    
    cin >> m;
    SI T_;
    for ( int i = 0; i < m; ++ i ) {
        int t;
        cin >> t;
        T_.insert(t);
    }
    m = T_.size();
    int ti = 0;
    for ( SI::iterator it_i = T_.begin(); it_i != T_.end(); ++ it_i ) {
        T[ti++] = *it_i;
    }
    return true;
}

LL solve() {
    LL dp[20][20][20];
    fill( (LL*)dp, (LL*)dp+20*20*20, 0 );
    dp[0][0][d_sum%10] = 1;
    for ( int i = 0; i < a_num; ++ i ) {
        for ( int j = 0; j < m; ++ j ) {
            for ( int k = 0; k < 10; ++ k ) {
                if ( dp[i][j][k] == 0 ) continue;
                for ( int nj = 0; nj < m; ++ nj ) {
                    int nk = ( k + get_b( C[i], T[nj] ) ) % 10;
                    dp[i+1][nj][nk] += dp[i][j][k];
                }
            }
        }
    }
    LL res = 0;
    for ( int i = 0; i < m; ++ i ) {
        res += dp[a_num][i][0];
    }
    return res;
}

int main() {
    while ( input() ) cout << solve() << endl;
    return 0;
}