#include using Int = int64_t; void Solve() { Int a, b; std::cin >> a >> b; Int x = 0; while (a--) { Int t; std::cin >> t; x = std::gcd(x, t); } Int y = 0; while (b--) { Int t; std::cin >> t; y = std::gcd(y, t); } std::cout << (y % x ? "No\n" : "Yes\n"); } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); Solve(); }