## https://yukicoder.me/problems/no/2944 def calc_gcd(A, B): """ 正の整数A, Bの最大公約数を計算する """ a = max(A, B) b = min(A, B) while a % b > 0: c = a % b a = b b = c return b def main(): a, b = map(int, input().split()) T = list(map(int, input().split())) S = list(map(int, input().split())) gcd_t = T[0] for i in range(1, a): gcd_t = calc_gcd(gcd_t, T[i]) for s in S: if s % gcd_t != 0: print("No") return print("Yes") if __name__ == "__main__": main()