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