import Data.List
main=getLine>>=print.e
 where e (c:s) = f (if c=='?' then ((replicate 10 1)++[0,0,0]) else (take 13 ((replicate (read [c]) 0)++(1:(repeat 0))))) s
       f l [] = l!!5
       f l (c:s) = let k=(map (l!!) [0,4,8,12,3,7,11,2,6,10,1,5,9]) in (if c=='?' then (f (g k) s) else (f (h (read [c]) k) s))
       g k = let kk=(reverse (k++k)) in (map (i kk) [12,11..0])
       h c k = ((drop (13-c) k)++(take (13-c) k))
       i k j = mod(sum(take 10 (drop j k)))1000000007