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 t in T:g=gcd(g,t) print("Yes" if all([s%g==0 for s in S]) else "No")