n, q = map(int, input().split()) for _ in range(q): x = int(input()) if x % n == 0 or str(n) in str(x): print('Yes') else: print('No')