#include #include using namespace std; using namespace atcoder; using ll = long long; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using vs = vector; using vp = vector>; #define rep(i, s, n) for (int i = (s); i < (int)(n); ++i) #define repr(i, s, n) for (int i = (s); i >= (int)(n); --i) #define sz(x) ((int)(x).size()) constexpr int INFI = 1001001001; constexpr ll INFL = (1LL << 60); string to_string(long long x) { if (x == 0) return "0"; string res; bool negative = false; if (x < 0) { negative = true; x = -x; } while (x > 0) { res += '0' + (x % 10); x /= 10; } if (negative) res += '-'; reverse(res.begin(), res.end()); return res; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; vi a (q); rep(i, 0, q){ cin >> a[i]; } string s = to_string(n); rep (i, 0, q){ bool jdg = 1; int x = a[i]; string t = to_string(x); int idx = t.find(s) == string::npos ? -1 : s.find(s); if(x % n == 0 || idx != -1){ cout << (jdg ? "Yes" : "No") << endl; } else{ jdg = 0; cout << (jdg ? "Yes" : "No") << endl; } } return 0; }