Problem:
 Score : 300 points    Problem Statement Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K .  She is shopping, and now paying at the cashier.
Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).  However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.  Find the amount of money that she will hand to the cashier.      Constraints  1 ≦ N < 10000  1 ≦ K < 10  0 ≦ D_1 < D_2 < … < D_K≦9  \{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}         Input The input is given from Standard Input in the following format:  N  K  D_1  D_2 … D_K       Output Print the amount of money that Iroha will hand to the cashier.        Sample Input 1 1000 8
1 3 4 5 6 7 8 9      Sample Output 1 2000  She dislikes all digits except 0 and 2 .  The smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2 , is 2000 .       Sample Input 2 9999 1
0      Sample Output 2 9999

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    N, K = i_map()
    D = i_list()

    for i in range(N,10*N+1):
        t = str(i)
        flg = True
        for j in D:
            if str(j) in t:
                flg = False
        if flg == True:
            print(i)
            exit()


if __name__=="__main__":
    main()

Solution (Python):
s = input()
s = s.split(" ")
N = s[0]
K = int(s[1])

s = input()
s = s.split(" ")
ds = [int(digit) for digit in s]

minNum = min([digit for digit in range(0, 10) if digit not in ds])
nonZerominNum = min([digit for digit in range(1, 10) if digit not in ds])
maxNum = max([digit for digit in range(0, 10) if digit not in ds])

digits = [int(digit) for digit in N]

result = N
for index in range(0, len(digits)):
  digit = digits[index]
  if digit in ds:
    i = index
    if digit > maxNum:
      i = index - 1
      while i >= 0 and digits[i] == maxNum:
        i -= 1
    
    if i < 0:
      result = str(nonZerominNum) + (str(minNum) * len(N))
    else:
      biggerDigit = min([d for d in range(0, 10) if d not in ds and d > digits[i]])
      digits[i] = biggerDigit
      for j in range(i+1, len(digits)):
        digits[j] = minNum
      result = "".join([str(digit) for digit in digits])
    break

print(result)

Solution (Python):
n,k=map(int,input().split())
l=list(map(int,input().split()))
for i in range(n,100000):
    s=str(i)
    d=list(map(int,s))
    f=0
    for j in range(len(d)):
        if(d[j] in l):
            f=1
    if(f==0):
        print(i)
        exit()

Solution (Python):
N, K=map(int,input().split())
D=list(map(int,input().split()))
for i in range (N,100000):
    a=str(i)
    b=list(map(int,a))
    l=len(b)
    c=0
    for j in range(l):
        if(b[j] in D):
            c=1
    if(c==0):
        ans=i
        break
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    N, K =MI()
    num = [1] * 10
    for m in LI():
        num[m] = 0
    

    def check(x):
        s = set(list(str(x)))
        return all([num[int(i)] for i in s])

    while 1:
        if check(N):
            print(N)
            return
        N += 1
    

if __name__ == '__main__':
    solve()

Solution (Python):
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict 
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  
  
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright





n,k=map(int,input().split())
D=list(map(str,input().split()))

for i in range(n,10**6):
    if any([j in D for j in str(i)]) ==0:
        print(i);exit()

Solution (Python):
n,k = map(int, input().split())
d = list(map(int, input().split()))
def v(n):
    for c in map(int, str(n)):
        if (c in d):
            return False
    return True
while (v(n) == False):
    n += 1
print(n)

Solution (Python):
n, k = map(int, input().split())
d = list(map(int, input().split()))
w = [False] * 10
for i in d:
	w[i] = True
def check(n):
	while n:
		if w[n % 10]:
			return False
		n //= 10
	return True
ans = n
while not check(ans):
	ans += 1
print(ans)

Solution (Python):
n, k =map(int, input().split())
d = list(map(int, input().split()))
a = [0]*10
for i in d:
  a[i]=1
  
ans = n
while True:
  flg = False
  temp = str(n)
  l = len(temp)
  for i in range(l):
    if a[int(temp[i])]==1:
      n+=1
      flg = True
      break
  if flg:
    continue
  else:
    print(n)
    quit()

Solution (Python):
def ume(n):
  st = str(n)
  le = len(st)
  re = ["0"]*le
  for i in range(le):
    if st[i]=="0":
      re[i]=str(m)
    else:
      re[i]=st[i]
  return int("".join(re))


n, k = map(int, input().split())
d = list(map(int, input().split()))
num = []


for i in range(10):
  if not i in d:
    num.append(i)

ds = str(n)
l = len(ds)
m = min(num)

if l == 1:
  for i in num:
    if i>=n:
      print(i)
      quit()

dp1=[0]*(l+1)

for i in num:
  if i != 0:
    ans = ume(i*(10**(l)))
    break

for i in num:
  flg = True
  if i == int(ds[0]):
    dp1[1]=i*(10**(l-1))
    flg = False
  if i > int(ds[0]):
    ans = ume(i*(10**(l-1)))
    break
    
if flg:
  print(ans)
  quit()

for i in range(1, l):
  flg = True
  flg2 = True
  for j in num:
    if j == int(ds[i]):
      dp1[i+1]=dp1[i]+j*(10**(l-1-i))
      flg = False
      flg2 = False
      break
    if j > int(ds[i]):
      flg2 = False
      ans = ume(dp1[i]+j*(10**(l-1-i)))
      if flg:
        print(ans)
        quit()
      break
  if flg2:
    print(ans)
    quit()
  
print(dp1[l])

Solution (Python):
n, k = map(int, input().split())
d = input().split()

def is_ok(num):
  s = str(num)
  for ng in d:
    if ng in s: return False
  
  return True

while True:
  if is_ok(n):
    print(n)
    exit()
  
  n += 1

Solution (Python):
n,k=map(int,input().split())
ar=list(map(int,input().split()))
def f(n):
    s=str(n)
    for el in ar:
        if(str(el) in s):
            return 0
    return 1
while(not f(n)):
    n+=1
print(n)

Solution (Python):
n,k=map(int,input().split())
D=set(map(str,input().split()))
ans=''
while True:
    tmp=set(list(str(n)))
    if len(D&tmp)==0:
        ans=n
        break
    n+=1
print(ans)

Solution (Python):
from itertools import permutations
n,k=map(int,input().split())
d=input().split()
i=n
while True:
  for j in str(i):
    if j in d:
      i+=1
      break
  else:
    print(i)
    break

Solution (Python):

(n, k) = map(int, input().split())
d = input().split()

ans = n
while True:
    check = True
    for dk in d:
        if dk in str(ans):
            check = False
            break
    if check:
        break
    ans += 1

print(ans)

Solution (Python):
n, k = map(int, input().split())
d = list(map(int, input().split()))
while True:
  n = str(n)
  flg = True
  for k in range(len(n)):
    if int(n[k]) in d:
      flg = False
      break
  if flg:
    ans = int(n)
    break
  n = int(n)
  n += 1
print(ans)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


N, K = map(int, input().split())
D = list(map(int, input().split()))

kouho = [i for i in range(10) if i not in D]

from queue import deque
q = deque([0])
while True:
    n = q.popleft()
    if n>=N:
        break
    for i in kouho:
        q.append(n*10+i)
print(n)

Solution (Python):
n,m = map(int,input().split())
l = list(map(int,input().split()))

for i in range(n,100000):
    k = i
    c=0
    while k>0:
        if k%10 not in l:
            c+=1
        else:
            break
        k = k//10
    if len(str(i))==c:
        print(i)
        break

Solution (Python):


import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,k,*d = map(int,read().split())


suki = [1]*10
for i in d: suki[i]=0

def check(i):
    while i:
        r = i%10
        if suki[r]==0: return False
        i//=10
    return True    

ans = 10**7
for i in range(10**6,0,-1):
    if i < n: break
    if check(i): ans = i

    
print(ans)

Solution (Python):
n, k = map(int, input().split())
d = set(range(10)) - set(map(int, input().split()))

i = n
while True:
    if (i >= n) and all(int(j) in d for j in str(i)):
        print(i)
        break
    i += 1

Solution (Python):
n, k = map(int, input().split())
d = set(range(10)) - set(map(int, input().split()))

i = n
while True:
    if (i >= n) and all(int(k) in d for k in str(i)):
        print(i)
        break
    i += 1

Solution (Python):
from itertools import product

n, k = map(int, input().split())
d = set(range(10)) - set(map(int, input().split()))

for i in product(d | set([0]), repeat=len(str(n)) + 1):
    i = int("".join(str(j) for j in i))
    if (i >= n) and all(int(k) in d for k in str(i)):
        print(i)
        break

Solution (Python):
n, k = map(int, input().split())
D = tuple(input().split())
while True:
    sn = str(n)
    for s in sn:
        if s in D:
            break
    else:
        break

    n += 1

print(n)

Solution (Python):
oldMoney, hateNumberLength = map(list, input().split())
hateLines = list(str(input()).rsplit(" "))
okLines = []
FirstBigList = []
newMoney = list(oldMoney)
 
 
def FindFirstBig(okLines, m, FirstBig):
    for i in okLines:
        if i > m:
            FirstBig.append(i)
            break
    return FirstBig
 
 
for i in range(10):
    if str(i) not in hateLines:
        okLines.append(str(i))
 
FirstFlag = -1
ProblemFlag = -1
for index, m in enumerate(oldMoney):
    if FirstFlag == -1:
        if m in hateLines:
            FirstBigList = FindFirstBig(okLines, m, FirstBigList)
            if len(FirstBigList) > 0:
                newMoney[index] = FirstBigList[0]
                FirstFlag = index
            ProblemFlag = index
    elif FirstFlag != -1:
        newMoney[index] = okLines[0]
 
if oldMoney == newMoney:
    if ProblemFlag is not 0 and ProblemFlag is not -1:
        FirstBigList.clear()
        while ProblemFlag:
            FirstBigList = FindFirstBig(okLines, newMoney[ProblemFlag - 1], FirstBigList)
            if len(FirstBigList) > 0:
                newMoney[ProblemFlag - 1] = FirstBigList[0]
                for i in range(ProblemFlag, len(newMoney), 1):
                    newMoney[i] = okLines[0]
            if oldMoney == newMoney:
                ProblemFlag -= 1
    if ProblemFlag is 0:
        if okLines[0] != '0':
            newMoney.insert(0, okLines[0])
        else:
            newMoney.insert(0, okLines[1])
        for i in range(ProblemFlag + 1, len(newMoney), 1):
            newMoney[i] = okLines[0]
resultnew = "".join(newMoney)
print(resultnew)

Solution (Python):
oldMoney, hateNumberLength = map(list, input().split())
hateLines = list(str(input()).rsplit(" "))
okLines = []
FirstBigList = []
newMoney = list(oldMoney)


def FindFirstBig(okLines, m, FirstBig):
    for i in okLines:
        if i > m:
            FirstBig.append(i)
    return FirstBig


for i in range(10):
    if str(i) not in hateLines:
        okLines.append(str(i))

FirstFlag = -1
ProblemFlag = -1
for index, m in enumerate(oldMoney):
    if FirstFlag == -1:
        if m in hateLines:
            FirstBigList = FindFirstBig(okLines, m, FirstBigList)
            if len(FirstBigList) > 0:
                newMoney[index] = FirstBigList[0]
                FirstFlag = index
            ProblemFlag = index
    elif FirstFlag != -1:
        newMoney[index] = okLines[0]

if oldMoney == newMoney:
    if ProblemFlag is not 0 and ProblemFlag is not -1:
        FirstBigList.clear()
        while ProblemFlag:
            FirstBigList = FindFirstBig(okLines, newMoney[ProblemFlag - 1], FirstBigList)
            if len(FirstBigList) > 0:
                newMoney[ProblemFlag - 1] = FirstBigList[0]
                for i in range(ProblemFlag, len(newMoney), 1):
                    newMoney[i] = okLines[0]
            if oldMoney == newMoney:
                ProblemFlag -= 1
    if ProblemFlag is 0:
        if okLines[0] != '0':
            newMoney.insert(0, okLines[0])
        else:
            newMoney.insert(0, okLines[1])
        for i in range(ProblemFlag + 1, len(newMoney), 1):
            newMoney[i] = okLines[0]
resultnew = "".join(newMoney)
print(resultnew)

Solution (Python):
N, K = map(int,input().split())
dislike = set(map(int,input().split()))
pay = N

while 1:
    digits = set(str(pay))
    digits = {int(d) for d in digits}
    if dislike.isdisjoint(digits): break
    else: pay += 1

print(pay)

Solution (Python):
a,b = map(int,input().split(" "))
ar = input().split(" ")
while True:
    count = 0
    for r in ar:
        if r in str(a):
            count += 1
            break
    if count == 0:
        print(a)
        break
    a += 1

Solution (Python):
n,k=[int(_) for _ in input().split()]
d=[_ for _ in input().split()]

for i in range(n,10*n):
  s =str(i)
  for c in s:
    if c in d:
      break
  else:
    print(i)
    exit()

Solution (Python):
input_1st=input()
input_2nd=input()

N, K = input_1st.split(" ")
D = input_2nd.split(" ")

for ans in range(int(N), 100000):
    flg = True
    for i in range(len(str(ans))):
        if str(ans)[i] in D:
          flg = False
          break

    if flg:
        print(ans)
        break

Solution (Python):
A,B = list(map(int,input().split()))
l_n = list(input().split())
sw = 0
for i in range(A,A*10+1):
    sw=0
    C = str(i)
    for j in C:
        if j in l_n:
            sw=1
            break
    if sw == 0:
        print(i)
        exit()

Solution (Python):
n, k = map(int, raw_input().strip().split())
diss = map(int, raw_input().strip().split())

like = [1] * 10
for d in diss: like[d] = 0

ok = 1
amt = n
for c in str(amt):
    if not like[int(c)]:
        ok = 0
        break

while not ok:
    amt += 1

    ok = 1
    for c in str(amt):
        if not like[int(c)]:
            ok = 0
            break

print amt

Solution (Python):
n, k = map(int, input().split())
d = list(map(int, input().split())) 

def check(n, d):
	
	
	s = str(n)
	for i in range(len(s)):
		if int(s[i]) in d:
			return False
	return True

res = n

while True:
	if check(res, d):
		print(res)
		break
	res += 1

Solution (Python):
N,K = input().split(' ')
line = input().split(' ')
for i in range(int(N),100000):
  m = True
  for j in range(len(str(i))):
    if str(i)[j] in line:
      m = False
      break
  if m == True:
    print(i)
    break

Solution (Python):
N, K = map(int, input().split())
D = list(input().split())

ans = N
for p in range(N, N+10**9):
    flag = True
    s = str(p)
    for c in s:
        if c in D:
            flag = False
            break

    if flag:
        break

print(s)

Solution (Python):
n, k = map(int, input().split())
d = list(input().split())
ans = 100000
for i in range(n, 100001):
    for j in range(k):
        if d[j] in str(i):
            break
    else:
        if ans > i:
            ans = i
print(ans)

Solution (Python):
import sys

rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    D = set(map(int, rl().split()))
    
    for ans in range(N, 100000):
        str_ans = str(ans)
        flg = True
        for a in str_ans:
            if int(a) in D:
                flg = False
                break
        if flg:
            print(ans)
            exit()


if __name__ == '__main__':
    solve()

Solution (Python):
N, K = map(int, input().split())
D = list(input().split())

for i in range(N, 10*N+1):
    s = str(i)
    for j in range(len(str(i))):
        if(s[j] in D):
            break
        if(j == len(str(i))-1):
            print(i)
            quit()

Solution (Python):
n, k = map(int, input().split())
d = list(input().split())

from itertools import count

for i in count(n):
    s = str(i)
    for bit in s:
        if bit in d:
            break
    else:
        print(i)
        break

Solution (Python):
n,m = input().split()
k=int(n)
l = list(input().split())

for i in range(k,100000):
    for e in l:
        if e in str(i):
            break
    else:
        print(i)
        break

Solution (Python):
n,m = input().split()
k=int(n)
li = list(input().split())

for i in range(k,100000):
    for e in li:
        if e in str(i):
            break
    else:
        print(i)
        break

Solution (Python):
N,K=map(int,input().split())
D=[1]*10
for i in map(int,input().split()):
  D[i]=0
ans=''
while N>0:
  n=N%10
  N=N//10
  while D[n%10]==0:
    n+=1
  if n>9:
    N+=1
  elif N>0 and D[N%10]==0:
    for i in range(n):
      if D[i]==1:
        n=i
        break
  ans+=str(n%10)
if ans=='':
  print(N)
else:
  print(ans[::-1])

Solution (Python):
n,k = map(int,input().split())
d = input().split()
ans = n-1
while True:
  ok = True
  ans += 1
  z = list(str(ans))
  for i in z:
    if i in d:
      ok = False
      break
  if ok:
    print(ans)
    break

Solution (Python):
N, M = map(int, input().split())
X = set(input().split())
for i in range(N, 10**6):
    for c in str(i):
        if c in X:
            break
    else:
        break
print(i)

Solution (Python):
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))

D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
for i in range(N):
    a=int(input())
    A.append(a)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''



N, K = map(int, input().split())
D = list(map(int,input().split()))

use = [True]*10
for d in D:
    use[d] = False

for pay in range(N, N*1000):
    
    can = True
    pay_string = str(pay)
    for p in pay_string:
        if not use[int(p)]:
            can = False
            break

    if can:
        print(pay)
        sys.exit()

Solution (Python):
n, k = list(map(int, input().split()))


digits = [0]*10
digits_disliked = list(map(int, input().split()))

for i in digits_disliked:
    digits[i] = 1

for i in range(n, 10**7+1):
    temp = i
    flag = True

    while(temp):
        rem = temp%10
        temp = temp//10
        if(digits[rem] != 0):
            flag = False
            break
    
    if(flag == True):
        print(i)
        break

Solution (Python):
n,k = input().split(" ")
l = input().split(" ")
l1 = ['0','1','2','3','4','5','6','7','8','9']
d = sorted(list(set(l1)-set(l)))
i = int(n)
while(True):
    if set(list(str(i))).difference(set(d))==set():
        break
    else:
        i+=1
print(i)

Solution (Python):
n,m = input().split()
k=int(n)
li = list(input().split())

for i in range(k,100000):
    for e in li:
        if e in str(i):
            break
    else:
        print(i)
        break

Solution (Python):
n, k = map(int, input().split())
d = map(str, input().split())
digits = set(d)
num = {str(i) for i in range(0,10)}
left = num - digits
for i in range(n, 100000):
    Nums = set(str(i))
    if Nums <= left:
        print(i)
        break

Solution (Python):

import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7

def main():
    N,K = cin.mapInt()
    D = set(cin.string().split())
    while True:
        if len(D & set(str(N))) == 0:
            break
        N +=1
    print(N)
    return

if __name__ == "__main__":
    main()

Solution (Python):
N,K = map(int,input().split())
D = list(map(int,input().split()))

flag = False

inf = 10 ** 6

while flag == False:
  for i in range(N,inf):
    L = str(i)
    for j in L:
      if int(j) in D:
        break
    else:
      print(i)
      flag = True
      break

Solution (Python):
s, k = [int(i) for i in input().split(" ")]
num = [int(i) for i in input().split(" ")]

def check(n):
	for _s in str(n):
		if int(_s) in num:
			return True
	return False

while check(s):
	s += 1
	
print(s)

Solution (Python):
n, k = map(int, input().split())

checker = list(map(str, input().split()))

cont = True
while cont:
    keep = True
    for nn in str(n):
        if nn in checker:
            keep = False
            break
        
    if keep: break
    n += 1

print(n)

Solution (Python):
N,K = map(int, input().split())
D = [int(d) for d in input().split()]

ans = 0
for i in range(N, 10**6):
    t = list(str(i))
    f = 0
    for s in t:
        if int(s) in D:
            break
        f += 1
    if f == len(t):
        print(i)
        break

Solution (Python):
N, K = map(int, input().split())
*D, = map(int, input().split())
D = set(D)
L = {1,2,3,4,5,6,7,8,9,0} - D
for i in range(N, N*10):
    tmp = i
    num = set()
    while i > 0:
        num.add(i%10)
        i = i // 10
    if num.isdisjoint(D):
        print(tmp)
        exit()

Solution (Python):
import sys
N,K=map(int,input().split())
D=[i for i in input().split()]

for i in range(N,100000):
    for d in D:
        if d in list(str(i)):
            break
    else:
        print(i)
        sys.exit()

Solution (Python):
n, k = map(int, input().split())
dlst = [int(i) for i in input().split()]
lst = []
for i in range(10):
  if i not in dlst:
    lst.append(str(i))
for i in range(n, 10 * n + 1):
  a = True
  for j in str(i):
    if j not in lst:
      a = False
      break
  if a:
    print(i)
    quit()

Solution (Python):
N, K = map(int, input().split())
A = [a for a in input().split()]

def chk(i):
    s = str(i)
    for a in s:
        if a in A:
            return 0
    return 1

i = N
while True:
    if chk(i):
        print(i)
        break
    i += 1

Solution (Python):
n,k = map(int,input().split())
d_L = list(map(str,input().split()))

a_L = [str(val) for val in range(10)]

use_num = list(set(a_L) - set(d_L))

ans = 0
while True:
    c = list(set(list(str(n)))) + use_num
    if len(use_num) == len(list(set(c))):
        print(n)
        exit()

    n += 1

Solution (Python):
def main():
    n,k = map(int,input().split())
    d = ''.join(input().split())
    ans=str(n)
    while True:
        key=0
        for c in d:
            if c in ans:
                key=1
                ans=str(int(ans)+1)
        if key==0:
            print(ans)
            return   

if __name__ == "__main__":
    main()

Solution (Python):
def des(n,D):
    if n%10 in D:
        return False
    elif n>=10 and (n//10)%10 in D:
        return False
    elif n>=100 and (n//100)%10 in D:
        return False
    elif n>=1000 and (n//1000)%10 in D:
        return False
    elif n>=10000 and n//10000 in D:
        return False
    return True

N,K=map(int,input().split())
D=list(map(int,input().split()))

while not des(N,D):
    N+=1
print(N)

Solution (Python):
n, k = map(int, input().split())
Ds = list(map(int, input().split()))

for i in range(n, n*11):
  for d in Ds:
    if d in list(map(int, list(str(i)))):
      break
  else:
    print(i)
    exit(0)

Solution (Python):
n,a=open(0)
n=int(n.split()[0])
while set(a)&set(str(n)):n+=1
print(n)

Solution (Python):
import itertools
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [str(i) for i in range(10) if i not in a]
anslist = b + list(itertools.product(b,b))
anslist += list(itertools.product(b,b,b))
anslist += list(itertools.product(b,b,b,b))
anslist += list(itertools.product(b,b,b,b,b))
anslist += list(itertools.product(b,b,b,b,b,b))
anslist = [int("".join(i)) for i in anslist ]


anslist.sort()
for i in anslist:
    if i >= n:
        print(i)
        exit()

Solution (Python):
import itertools
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [str(i) for i in range(10) if i not in a]
anslist = b + list(itertools.product(b,b))
anslist += list(itertools.product(b,b,b))
anslist += list(itertools.product(b,b,b,b))
anslist += list(itertools.product(b,b,b,b,b))
anslist += list(itertools.product(b,b,b,b,b,b))
anslist = [int("".join(i)) for i in anslist ]


anslist.sort()
for i in anslist:
    if i >= n:
        print(i)
        exit()

Solution (Python):

def main():
    N, K, *D = map(int, open(0).read().split())
    D = set(D)
    while any(int(i) in D for i in str(N)):
        N += 1
    print(N)


if __name__ == "__main__":
    main()

Solution (Python):
n,k=map(int,input().split())
d=list(input().split())

while True:
    ok=True
    for c in str(n):
        if c in d:
            ok=False
            break
    if ok:
        print(n)
        break
    else:
        n+=1

Solution (Python):
N, K = map(int, input().split())
D = list(map(int, input().split()))

def isntD(n):
    c = 0
    for i in range(len(str(n))):
        if D.count(int(str(n)[i])) == 1:
            c += 1
    return c
    

while N < 100000:
    if isntD(N) == 0:
        print(N)
        break
    N += 1

Solution (Python):
N,K=map(int,input().split())
D=[x for x in input().split()]

while True:
	f=True
	for d in D:
		if d in str(N):f=False
	if f:
		print(N)
		break
	N+=1

Solution (Python):
N,K = map(int,input().split())
D = list(map(int,input().split()))
U = []
for i in range(10):
    if not i in D:
        U.append(i)
ans = float("inf")
import itertools

for i in range(6):
    for v in itertools.product(U,repeat=i):
        tmp = ""
        for s in v:
            tmp += str(s)
        if tmp != "":
            tmp = int(tmp)
            if tmp>=N and tmp<ans:
                ans = tmp
print(ans)

Solution (Python):
N, K = map(int, input().split())
D = set(input().split())

ans = N
while any([i in D for i in str(ans)]):
    ans += 1

print(ans)

Solution (Python):
N, K = map(int, input().split())
D = [int(i) for i in input().split()]
M = N

while True:
  S = str(M)
  flag = 0
  for s in S:
    if int(s) in D:
      M += 1
      break
  else:
    break
print(S)

Solution (Python):
N, K = map(int, input().split())
D = set(input().split())

safe = set([str(i) for i in range(10) if not str(i) in D])

ans = N
while not all([i in safe for i in str(ans)]):
    ans += 1

print(ans)

Solution (Python):
N,K = map(int,input().split())
D = list(map(int,input().split()))

while 1:
    for d in str(N):
        if int(d) in D:
            break
    else:
        print(N)
        exit()
    N += 1

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    d = {str(i): 0 for i in list(map(int, input().rstrip('\n').split()))}

    for i in range(n, 10 ** 15):
        t = str(i)
        b = True
        for j in range(len(t)):
            if t[j] in d:
                b = False
                break
        if b:
            print(i)
            exit()


if __name__ == '__main__':
    slove()

Solution (Python):
n, k = map(int, input().split())
li_d = list(input().split())

answer = n

while not all(w not in li_d for w in str(answer)):
    answer += 1

print(answer)

Solution (Python):
n, k = map(int, input().split())
a = list(input().split())
for i in range(n, 10**6):
  if all([j not in a for j in str(i)]):
 
    print(i)
    exit()

Solution (Python):
N, K = map(int, input().split())
D = set(map(str, input().split()))

while True:
    S = str(N)
    hit = True
    for s in S:
        if s in D:
            N += 1
            hit = False
            break
    if hit:
        print(N)
        exit()

Solution (Python):
n, k = [int(x) for x in input().split(' ')]
d = set(x for x in input().split(' '))

for i in range(100000):
    if set(str(i)).isdisjoint(d) and i >= n:
        print(i)
        exit()

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    d = list(map(int, input().rstrip('\n').split()))
    for i in range(n, 10 ** 10):
        t = list(str(i))
        b = True
        for j in range(len(t)):
            if int(t[j]) in d:
                b = False
                break
        if b:
            print(i)
            exit()


if __name__ == '__main__':
    slove()

Solution (Python):
import itertools
n, k = map(int, input().split())
d = list(map(int, input().split()))
u = []
for i in range(0, 10):
    if i not in d:
        u.append(i)
for j in range(1, 6):
    for i in itertools.product(u, repeat=j):
        t = int("".join(map(str, i)))
        if n <= t <= 100000:
            print(t)
            exit()