from math import gcd
a, b = map(int, input().split())
T = list(map(int, input().split()))
S = list(map(int, input().split()))
g = T[0]
for i in T[1:]:
	g = gcd(g, i)
for i in S:
	if i % g:
		exit(print("No"))
print("Yes")