from math import gcd a,b = map(int,input().split()) T = list(map(int,input().split())) S = list(map(int,input().split())) x = 0 for t in T: x = gcd(x,t) for s in S: if s % x != 0: print("No") exit() print("Yes")