from math import gcd a, b = map(int, input().split()) T = list(map(int, input().split())) S = list(map(int, input().split())) g = gcd(*T) if all(s % g == 0 for s in S): print('Yes') else: print('No')