            let values = readLine()!.characters.split{ x in x == " "}.map{Int(String($0))!}
            let N = values[0]
            let D = readLine()!.characters.split{ x in x == " "}.map{Int(String($0))!}

            for i in N ... 10000 {
                let str = String(i)
                for d in D {
                    if str.rangeOfString(String(d)) != nil {
                        continue
                    } else {
                        print(str)
                    }
                }
            }