#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin >> N >> M; int g = 0; while(N--){ int a; cin >> a; g = gcd(a,g); } bool ok = true; while(M--){ int b; cin >> b; if(b%g) ok = false; } if(ok) cout << "Yes" << endl; else cout << "No" << endl; }