from math import* a,b=map(int,input().split()) T=list(map(int,input().split())) S=list(map(int,input().split())) T_gcd=None if a==1: T_gcd=T[0] else: T_gcd=gcd(T[0], T[1]) for i in range(1, len(T)): T_gcd=gcd(T_gcd, T[i]) T_mod_set=set() S_mod_set=set() for elm in T: T_mod_set.add(elm%T_gcd) for elm in S: S_mod_set.add(elm%T_gcd) flag=True for elm in S_mod_set: if elm not in T_mod_set: flag=False print(["No","Yes"][flag])