a, b = map(int, input().split()) T = list(map(int, input().split())) S = list(map(int, input().split())) if len(set(T)) == 1: if all(s % T[0] == 0 for s in S): print('Yes') else: print('No') exit() if all(t & 1 == 0 for t in T): if any(s & 1 for s in S): print('No') else: print('Yes') exit() if any(t & 1 for t in T): print('Yes') exit() print('No')