#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; VVI to(n); vector

edges; rep(i, n) { int a, b; cin >> a >> b; a--, b--; to[a].emplace_back(b); to[b].emplace_back(a); edges.emplace_back(a, b); } vector visited(n); VI st; VI cycle; auto dfs1 = [&](auto&& self, int u, int p) -> void { if (visited[u]) { cycle = VI(find(all(st), u), st.end()); return; } visited[u] = true; st.emplace_back(u); for(int v: to[u]) if (v != p) { self(self, v, u); if (!cycle.empty()) return; } st.pop_back(); }; dfs1(dfs1, 0, -1); assert(cycle.size()); vector in_cycle(n); for(char v: cycle) in_cycle[v] = true; map dir; auto add = [&](int u, int v) { if (u > v) dir[{v, u}] = 1; else dir[{u, v}] = 0; }; rep(i, cycle.size()) { int u = cycle[i], v = cycle[(i + 1) % cycle.size()]; add(u, v); } auto dfs2 = [&](auto&& self, int u, int p) -> void { for(int v: to[u]) if (v != p && !in_cycle[v]) { add(v, u); self(self, v, u); } }; for(int r : cycle) dfs2(dfs2, r, -1); for(auto [u, v] : edges) { assert(dir.count({u, v})); int d = dir[{u, v}]; cout << (d == 0 ? "->" : "<-") << '\n'; } }