MULTII  Yet Another Multiple Problem
Given a positive integer N (1 <= N <= 10000) and some digits, find the smallest positive multiple of N whose decimal notation does not contain any of the given digits.
Input
Each test case contains two lines. The first line contains two integers N and m separated by a single space. The second line contains m digits separated by spaces. Input terminates by EOF.
Output
For each test case output its case number (starting from 1) and the answer in a single line, or "1" (without quotes) if the answer doesn't exist.
Example
Input: 2345 3 7 8 9 100 1 0 Output: Case 1: 2345 Case 2: 1
hide comments
mehulcoder:
20201014 22:06:08
Can someone please help me!!!! Why am I getting TLE? The output seems fine to me


mahmoud_acm5:
20190906 22:32:56
i solved it in 0.72 ms but have something missing about when it will end i solve it but can't prove it now should i draw a tree or something on paper ? Last edit: 20200711 01:15:53 

sarwar__05:
20180425 17:17:43
similar one: http://www.spoj.com/problems/ONEZERO/en/ 

(Tjandra Satria Gunawan)(æ›¾æ¯…æ˜†):
20141113 20:52:24
Finally accepted ;)


Bharath Reddy:
20140924 18:57:51
Not so easy for me :D


abdelkarim:
20130807 01:34:26
easy one! 

Darko Aleksic:
20121211 22:24:17
Got RTE when trying to print the number recursively. This is a general request  can the Java stack be increased?


devu:
20121201 08:19:35
Could You Just tell me the maximum length of the answer which would be coming..


(Tjandra Satria Gunawan)(æ›¾æ¯…æ˜†):
20121121 17:48:31
Ok, I give up, this problem is too hard for me for now...

Added by:  Fudan University Problem Setters 
Date:  20121121 
Time limit:  4s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  ACM/ICPC Regional Contest, Chengdu 2012 