program main
    implicit none
    integer i, j, k
    integer n_len, tg, pop
    integer :: mod_ = 10**9+7
    integer, allocatable :: dp(:),old_dp(:)
    character(10**5):: S

    read*, S
    n_len = len_trim(S)
    allocate(dp(0:12), old_dp(0:12))
    dp(0:12) = 0
    dp(0) = 1
    old_dp(0:12) = 0
    
    do i=1, n_len
        old_dp(0:12) = dp(0:12)
        dp(0:12) = 0

        if(S(i:i) == "?")then
            do j = 0,9
                do k=0,12
                    pop = mod(k*10+j,13)
                    dp(pop) = dp(pop) + old_dp(k)
                    dp(pop) = mod(dp(pop),mod_)
                enddo
            enddo

        else
            read(S(i:i),*) tg
            do k=0,12
                pop = mod(k*10+tg,13)
                dp(pop) = dp(pop) + old_dp(k)
                dp(pop) = mod(dp(pop),mod_)
            enddo
        endif

    enddo

print'(i0)', dp(5)

stop
end program main