from math import gcd a, b = map(int, input().split()) T = [int(t) for t in input().split()] gcdT = T[0] for i in range(1, a): gcdT = gcd(gcdT, T[i]) S = [int(s) for s in input().split()] gcdS = S[0] for j in range(1, b): gcdS = gcd(gcdS, S[j]) print("No" if gcdS % gcdT else "Yes")