def parse lines
  lines = lines.map(&:chomp)
  [ lines[0].to_i, lines[1], lines[2].to_i, lines[3].split ]
end

def fold n
  if n >= 10
    n.to_s.chars.map(&:to_i).inject(:+)
  else
    n
  end
end

def valid? id
  id.chars.map(&:to_i).reverse.map.with_index(1) { |n, i|
    i.even? ? fold(n*2) : n
  }.inject(:+) % 10 == 0
end

def complete id, alts
  i = -1
  id.gsub('*') { i += 1; alts[i]; }
end

def nsolutions id, alts
  alts.repeated_permutation(id.chars.count('*')).map { |alts|
    valid?(complete(id, alts))
  }.count(true)
end

n, id, m, a = parse STDIN.each_line.take(4)

p nsolutions(id, a)