n,q=map(int,input().split()) for _ in range(q): x=int(input()) if x%n==0: print('Yes') continue x=list(str(x)) tmp=list(str(n)) ans='No' for i in range(len(x)-len(tmp)): tag=True for j in range(len(tmp)): if x[i+j]!=tmp[i+j]: tag=False if tag==True: ans='Yes' print(ans)