from collections import defaultdict class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def members_count(self): dic=defaultdict(int) for i in range(self.n): dic[self.find(i)]+=1 return dic def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): group_members = defaultdict(list) for member in range(self.n): group_members[self.find(member)].append(member) return group_members def __str__(self): return '\n'.join(f'{r}: {m}' for r, m in self.all_group_members().items()) N,M=map(int,input().split()) uf=UnionFind(N) no_flag=False edge=[[] for _ in range(N)] for _ in range(M): i,E,j=map(str,input().split()) i=int(i) j=int(j) i-=1 j-=1 if E=='<==>': uf.union(i,j) else: edge[i].append(j) edge[j].append(i) edge2=[[] for _ in range(N)] for i in range(N): f1=uf.find(i) for e in edge[i]: f2=uf.find(e) if f1==f2: print('No') exit(0) else: edge2[f1].append(f2) edge2[f2].append(f1) edge=edge2 from collections import deque def bfs(s): dq=deque() dq.append([s,0]) global dist while len(dq)!=0: p,h=dq.popleft() for e in edge[p]: if dist[e]==-1: dq.append([e,h+1]) dist[e]=1-dist[p] for d in dic[e]: ans[1-dist[p]].append(d) elif dist[e]!=1-dist[p]: print('No') exit(0) return roots=uf.roots() dist=[-1 for _ in range(N)] dic=uf.all_group_members() ans=[[],[]] for r in roots: if dist[r]==-1: dist[r]=1 for d in dic[r]: ans[1].append(d) bfs(r) print('Yes') if len(ans[0])>len(ans[1]): print(len(ans[0])) print(*sorted([a+1 for a in ans[0]])) else: print(len(ans[1])) print(*sorted([a+1 for a in ans[1]]))