Submit: 1 Solved: 1

[Submit] [Status] [Web Board] [Creator:]

There are tons of problems about integer multiples. Despite the fact that the topic is not original, the content is highly challenging. That’s why we call it “Yet Another Multiple Problem”.

In this problem, you’re asked to solve the following question: Given a positive integer n and m decimal digits, what is the minimal positive multiple of n whose decimal notation does not contain any of the given digits?

There are several test cases.

For each test case, there are two lines. The first line contains two integers n and m (1 ≤ n ≤ 10^{4}). The second line contains m decimal digits separated by spaces.

Input is terminated by EOF.

For each test case, there are two lines. The first line contains two integers n and m (1 ≤ n ≤ 10

Input is terminated by EOF.

For each test case, output one line “Case X: Y” where X is the test case number (starting from 1) while Y is the minimal multiple satisfying the above-mentioned conditions or “-1” (without quotation marks) in case there does not exist such a multiple.

```
2345 3
7 8 9
100 1
0
```

```
Case 1: 2345
Case 2: -1
```