#include using namespace std; using ll = long long; struct UnionFind { int ngroup, N; vector par, siz, mn; UnionFind(int _N) : N(_N), par(_N), siz(_N), mn(_N) { ngroup = _N; for(int i = 0; i < N; i++) par[i] = i, siz[i] = 1, mn[i] = i; } int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); } int unite(int x, int y) { int rx = root(x), ry = root(y); if (rx == ry) return rx; ngroup--; if (siz[rx] > siz[ry]) swap(rx, ry); par[rx] = ry; siz[ry] += siz[rx]; mn[ry] = min(mn[rx], mn[ry]); return ry; } bool same(int x, int y) { int rx = root(x), ry = root(y); return rx == ry; } int size(int x) {return siz[root(x)];} int mindex (int x) {return mn[root(x)];} //xを含む連結成分の最小の頂点番号 int group_count() {return ngroup;} vector> groups(){ vector rev(N); int nrt=0; for (int i=0; i> res(nrt); for (int i=0; i> N >> M; vector> E(N); UnionFind tree(N); vector g(N), color(N, -1); string S; vector> a, b; for (int i=0; i> x >> S >> y; x--; y--; if (S == "<==>") a.push_back({x, y}); else b.push_back({x, y}); } for (auto [x, y] : b){ E[x].push_back(y); E[y].push_back(x); } auto dfs=[&](auto self, int from, int c)->void{ color[from] = c; g[from] = cnt; for (auto to : E[from]){ if (color[to] != -1){ if (color[from] == color[to]){ cout << "No" << endl; exit(0); } else continue; } self(self, to, 1-c); } }; for (int i=0; i ans, aa, bb; for (int i=0; i