from math import gcd A, B = map(int, input().split()) S = list(map(int, input().split())) T = list(map(int, input().split())) gs, gt = S[0], T[0] for i in S: gs = gcd(gs, i) for i in T: gt = gcd(gt, i) if gt % gs == 0: print("Yes") else: print("No")