a,b = map(int,input().split()) T = list(map(int,input().split())) S = list(map(int,input().split())) def gcd(a,b): while b: a,b = b,a % b return a now = T[0] for i in range(1,a): now = gcd(now,T[i]) import sys for s in S: if s % now != 0: print('No') exit() print('Yes')