Multiple#476

Multiple

1 second
64 megabytes
Hard

Write a program to find the smallest positive integer that consists only of the given digits and is divisible by the specified integer .

Input

The first line contains the integer (1 < N < 5000). The second line contains from to distinct digits that can be used to construct the number .

Output

Print the found integer on the first line, or print if no such number exists.

Examples

Example 1

Loading
Loading