import math a,b=map(int,input().split()) T=0 for t in map(int,input().split()): T=math.gcd(T,t) S=0 for s in map(int,input().split()): S=math.gcd(S,s) if T%S==0: ans="Yes" else: ans="No" print(ans)