class UnionFind: def __init__(self, n): self.data = [-1] * (n + 1) self.nexts = [-1] * (n + 1) # 次の要素(なければ-1) self.tails = list(range(n + 1)) # 末尾の要素 def root(self, a: int) -> int: if self.data[a] < 0: return a self.data[a] = self.root(self.data[a]) return self.data[a] def unite(self, a: int, b: int) -> bool: pa = self.root(a) pb = self.root(b) if pa == pb: return False if self.data[pa] > self.data[pb]: pa, pb = pb, pa self.data[pa] += self.data[pb] # pa を pb をつなげる self.data[pb] = pa # pa の末尾に pb を繋げる self.nexts[self.tails[pa]] = pb self.tails[pa] = self.tails[pb] return True def issame(self, a: int, b: int) -> bool: return self.root(a) == self.root(b) def size(self, a: int) -> int: """a が属する集合のサイズ""" return -self.data[self.root(a)] def group(self, a): """a が属する集合""" v = self.root(a) while v != -1: yield v v = self.nexts[v] N, M = map(int, input().split()) uf = UnionFind(N * 2 + 10) for _ in range(M): A, B = map(int, input().split()) uf.unite(A, B + N) uf.unite(A + N, B) for i in range(1, N+1): if not uf.issame(i, i+N): print('No') break else: print('Yes')