n, q = io.read("*n", "*n") ns = tostring(n) for i = 1, q do x = io.read("*n") xs = tostring(x) if x % n == 0 or xs:find(ns) then print("Yes") else print("No") end end