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) and any(s & 1 for s in S): print('No') exit() print('Yes')