Problems
Many number
Many number
Given a positive integer \textbf{K} and a set of numbers \textbf{S}. Required to find the minimal positive integer divisible by \textbf{K}, in decimal notation that there are only numbers from the set \textbf{S}. Also in the desired number of decimal should not be two consecutive identical digits.
\InputFile
The first line contains a set of allowable numbers of \textbf{S} in ascending order without gaps and without repetition. A set of numbers may be empty. The second line contains the number of \textbf{K} (\textbf{1} <= \textbf{K} <= \textbf{10^5}).
\OutputFile
Remove one of the required number. If the desired number does not exist, output a \textbf{--1}.
Input example #1
12 7
Output example #1
21