class UnionFind: def __init__(self, n, w=None): self.par = [-1]*n self.rank = [0]*n self.siz = [1]*n self.cnt = n self.min_node = [i for i in range(n)] self.weight = w if w else [1]*n def root(self, x): if self.par[x] == -1: return x self.par[x] = self.root(self.par[x]) return self.par[x] def issame(self, x, y): return self.root(x) == self.root(y) def unite(self, x, y): px = self.root(x) py = self.root(y) if px == py: return False if self.rank[px] < self.rank[py]: px, py = py, px self.par[py] = px if self.rank[px] == self.rank[py]: self.rank[px] += 1 self.siz[px] += self.siz[py] self.cnt -= 1 self.min_node[px] = min(self.min_node[px], self.min_node[py]) self.weight[px] += self.weight[py] return False def count(self): return self.cnt def min(self, x): return self.min_node[self.root(x)] def getweight(self, x): return self.weight[self.root(x)] def size(self, x): return self.siz[self.root(x)] import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline N, M = map(int, input().split()) iEj = [input().split() for _ in range(M)] UF = UnionFind(N) for i, E, j in iEj: i = int(i) j = int(j) i-=1 j-=1 if E=="<==>": UF.unite(i, j) D = dict() Z = [] for i in range(N): r = UF.root(i) if r not in D: D[r] = len(D) Z.append(r) G = [[] for _ in range(len(D))] UF2 = UnionFind(len(D)) for i, E, j in iEj: i = int(i) j = int(j) i-=1 j-=1 if E=="<=/=>": ri = UF.root(i) rj = UF.root(j) if ri==rj: print("No") exit() G[D[ri]].append(D[rj]) G[D[rj]].append(D[ri]) UF2.unite(D[ri], D[rj]) color = [0] * len(D) # 頂点を1と-1で塗っていく def dfs(v, c): color[v] = c # 頂点vをcで塗る for i in range(len(G[v])): # 隣接している頂点が同じ色ならFalse if color[G[v][i]] == c: return False # 隣接している頂点がまだ塗られていないなら-cで塗る if color[G[v][i]] == 0 and not dfs(G[v][i], -c): return False # すべての頂点を塗れたらTrue return True for i in range(len(D)): if color[i] == 0: # まだ頂点iが塗られていなければ1で塗る if not dfs(i, 1): print("No") exit() color_cnt = dict() color_group = dict() for i in range(len(D)): ri = UF2.root(i) if ri not in color_cnt: color_cnt[ri] = [0, 0] color_group[ri] = [[], []] c = color[i] if c==1: color_cnt[ri][1] += UF.size(Z[i]) color_group[ri][1].append(Z[i]) else: color_cnt[ri][0] += UF.size(Z[i]) color_group[ri][0].append(Z[i]) cnt = 0 group = [] for key in color_cnt: cnt0, cnt1 = color_cnt[key] if cnt0 cnt: print("No") exit() group = set(group) ans = [] for i in range(N): ri = UF.root(i) if ri in group: ans.append(i+1) print("Yes") print(len(ans)) print(*ans)