fun main(args:Array<String>):Unit {
    val n = readLine()!!.trim().toInt()
    val id = readLine()!!.trim().toCharArray()
    readLine()
    val suspects = readLine()!!.trim().split(' ').map(String::toInt)
    var sum = 0
    for (i in 1 .. n){
        sum += if (id[n - i] == '*')
        {
            0
        }else if (i % 2 == 1){
            id[n - i].toString().toInt()
        }else {
            if (id[n - i].toString().toInt() * 2 >= 10){
                (id[n - i].toString().toInt() * 2).let{ it / 10 + it % 10}
            }else{
                id[n - i].toString().toInt() * 2
            }
        }
    }
    val wildcard = id.mapIndexed { index, c -> Pair(n - index, c) }.filter{it.second == '*'}.map{
        if (it.first % 2 == 1){
            suspects
        }else{
            suspects.map{
                if (it * 2 >= 10) it * 2 / 10 + it * 2 % 10
                else it * 2
            }
        }.toIntArray()
    }.toTypedArray()
    println(calPattern(wildcard, 0, sum))

}
fun calPattern(suspects:Array<IntArray>, idx:Int, sum:Int, memo:Array<IntArray> = Array(10){Array(10){-1}.toIntArray()}):Int {
    if (idx == suspects.size) return if (sum % 10 == 0) 1 else 0
    if (memo[sum % 10][idx] >= 0) return memo[sum % 10][idx]
    memo[sum % 10][idx] = 0
    for (n in suspects[idx]){
        memo[sum % 10][idx] += calPattern(suspects, idx + 1, sum + n, memo)
    }
    return memo[sum % 10][idx]
}
