N,Q = map(int,input().split()) X = [int(input()) for i in range(Q)] for x in X: if x%N==0 or str(N) in str(x): print('Yes') else: print('No')