#include #define rep(i, n) for (int i = 0; i < n; ++i) typedef long long ll; using namespace std; struct Namori { vector> forest; vector loop; Namori(vector> &G) { int N = G.size(); vector deg(N); forest.resize(N); rep(i, N) deg[i] = G[i].size(); queue q; vector seen(N); rep(i, N) { if (deg[i] == 1) { q.emplace(i); seen[i] = true; } } while (!q.empty()) { int u = q.front(); q.pop(); for (int v : G[u]) { if (seen[v]) continue; deg[v]--; forest[u].emplace_back(v); forest[v].emplace_back(u); if (deg[v] == 1) { q.emplace(v); seen[v] = true; } } } rep(i, N) { if (!seen[i]) loop.emplace_back(i); } } }; int main() { cin.tie(0)->sync_with_stdio(0); int N; cin >> N; vector> G(N); map, int> ids; rep(i, N) { int u, v; cin >> u >> v; u--, v--; ids[{u, v}] = i; ids[{v, u}] = i + N; G[u].emplace_back(v); G[v].emplace_back(u); } Namori g(G); vector ans(2 * N); rep(i, g.loop.size()) { int u = g.loop[i], v = g.loop[(i + 1) % g.loop.size()]; ans[ids[{u, v}]] = 1; if (g.forest[u].size() == 0) continue; reverse(g.forest[u].begin(), g.forest[u].end()); g.forest[u].emplace_back(u); rep(j, g.forest[u].size() - 1) { ans[ids[{g.forest[u][j], g.forest[u][j + 1]}]] = 1; } } rep(i, N) { if (ans[i] == 1) cout << "->\n"; else cout << "<-\n"; } return 0; }