#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int a, b; cin >> a >> b; vector s(a), t(b); rep(i, a) cin >> s[i]; rep(i, b) cin >> t[i]; sort(s.begin(), s.end()); if (b == 0) { cout << "Yes" << endl; } else if (a == 0) { cout << "No" << endl; } else { int g = accumulate(s.begin(), s.end(), 0, gcd); bool exi = false; rep(i, b) { if (t[i] % g != 0) { exi = true; break; } } cout << (exi ? "No" : "Yes") << endl; } return 0; }