#include #define rep(i, n) for (int i = 0; i < n; ++i) typedef long long ll; using namespace std; int main() { cin.tie(0)->sync_with_stdio(0); int N; cin >> N; map, int> edges; vector> G(N); rep(i, N) { int u, v; cin >> u >> v; u--, v--; edges[{u, v}] = i; edges[{v, u}] = -i; G[u].emplace_back(v); G[v].emplace_back(u); } vector deg(N); rep(i, N) deg[i] = G[i].size(); vector loop; { vector seen(N); queue q; rep(i, N) { if (deg[i] == 1) { q.push(i); seen[i] = true; } } while (!q.empty()) { int u = q.front(); q.pop(); for (int v : G[u]) { if (seen[v]) continue; deg[v]--; if (deg[v] == 1) { q.push(v); seen[v] = true; } } } rep(i, N) { if (!seen[i]) { auto dfs = [&](auto &&self, int u, int p) -> void { loop.emplace_back(u); seen[u] = true; for (int v : G[u]) { if (v == p) continue; if (seen[v]) continue; self(self, v, u); } }; dfs(dfs, i, -1); break; } } } int n = loop.size(); vector ans(N); rep(i, n) { int u = loop[i]; int v = loop[(i + 1) % n]; int id = edges[{u, v}]; if (id >= 0) { ans[id] = 1; } else { ans[-id] = 2; } } vector seen(N); rep(i, n) seen[loop[i]] = true; rep(i, n) { auto dfs = [&](auto &&self, int u, int p = -1) -> void { for (int v : G[u]) { if (v == p) continue; if (seen[v]) continue; seen[v] = true; int id = edges[{u, v}]; if (id > 0) { ans[id] = 2; } else { ans[-id] = 1; } self(self, v, u); } }; dfs(dfs, loop[i]); } rep(i, N) { if (ans[i] == 1) cout << "->\n"; else cout << "<-\n"; } return 0; }