import sys sys.setrecursionlimit(2 * 10**3) if sys.implementation.name == "pypy": import pypyjit pypyjit.set_param("max_unroll_recursion=-1") from collections import defaultdict input = lambda: sys.stdin.readline().rstrip() class UnionFind: def __init__(self, N): self.N = N self.parent_or_size = [-1] * N self.group_count = N def root(self, x): if self.parent_or_size[x] < 0: return x else: self.parent_or_size[x] = self.root(self.parent_or_size[x]) return self.parent_or_size[x] def unite(self, x, y): root_x = self.root(x) root_y = self.root(y) if root_x == root_y: return if -self.parent_or_size[root_x] < -self.parent_or_size[root_y]: root_x, root_y = root_y, root_x self.parent_or_size[root_x] += self.parent_or_size[root_y] self.parent_or_size[root_y] = root_x self.group_count -= 1 def same(self, x, y): return self.root(x) == self.root(y) def size(self, x): return -self.parent_or_size[self.root(x)] def groups(self): ret = defaultdict(list) for i in range(self.N): ret[self.root(i)].append(i) return [group for group in ret.values()] N, M = map(int, input().split()) uf = UnionFind(N * 2) related = UnionFind(N) for _ in range(M): i, s, j = input().split() i = int(i) - 1 j = int(j) - 1 if len(s) == 4: uf.unite(i, j) uf.unite(i + N, j + N) else: uf.unite(i, j + N) uf.unite(i + N, j) related.unite(i, j) for i in range(N): if uf.same(i, i + N): print("No") exit() ans = [] for grp in related.groups(): cand1 = [] cand2 = [] f = grp[0] for node in grp: if uf.same(f, node): cand1.append(node + 1) else: cand2.append(node + 1) if len(cand1) > len(cand2): ans.extend(cand1) else: ans.extend(cand2) if len(ans) >= N // 2: print("Yes") print(len(ans)) print(*sorted(ans)) else: print("No")