/** * - Meet Brahmbhatt * - Hard work always pays off **/ #include"bits/stdc++.h" using namespace std; #ifdef MeetBrahmbhatt #include "debug.h" #else #define dbg(...) 72 #endif #define endl "\n" #define int long long const long long INF = 4e18; const int32_t M = 1e9 + 7; const int32_t MM = 998244353; void solve() { int n; cin >> n; vector>> G(n); vector deg(n); vector> E(n); for (int i = 0; i < n; i++) { int u, v; cin >> u >> v; --u; --v; deg[u]++; deg[v]++; E[i] = {u, v}; G[u].push_back({v, i}); G[v].push_back({u, i}); } vector vis(n); queue Q; for (int i = 0; i < n; ++i) { if (deg[i] == 1) { vis[i] = 1; Q.push(i); } } vector ans(n); while (!Q.empty()) { int u = Q.front(); Q.pop(); deg[u] = 0; for (auto [to, id] : G[u]) { if(deg[to] > 1) ans[id] = E[id][0] == u ? "->" : "<-"; if (!vis[to] and --deg[to] == 1) { vis[to] = 1; Q.push(to); } } } function dfs = [&](int u, int par) { for (auto [to, id] : G[u]) { if (deg[to] > 1 and to != par) { deg[to]--; ans[id] = E[id][0] == u ? "->" : "<-"; dfs(to, u); break; } } }; for (int i = 0; i < n; i++) { if (!vis[i]) { dfs(i, -1); break; } } for (int i = 0; i < n; i++) { cout << ans[i] << "\n"; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(9); int tt = 1; // cin >> tt; while (tt--) solve(); return 0; }