#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int N,A[2 << 17],B[2 << 17],seen[2 << 17],finished[2 << 17],depth[2 << 17]; vector tmp,G[2 << 17]; int s = -1; void dfs(int u,int p) { seen[u] = 1; tmp.push_back(u); for(int v:G[u]) { if(finished[v] || v == p) continue; if(seen[v] && !finished[v]) { s = v; return; } dfs(v,u); if(s >= 0) return; } tmp.pop_back(); finished[u] = 1; } set C; void dfs2(int u,int p,int d) { depth[u] = d; for(int v:G[u]) if(v != p && !C.count(v)) dfs2(v,u,d+1); } void solve() { cin >> N; for(int i = 0;i < N;i++) { cin >> A[i] >> B[i],A[i]--,B[i]--; G[A[i]].push_back(B[i]); G[B[i]].push_back(A[i]); } dfs(0,-1); set> ST; int pu = -1,su = -1; while(1) { int u = tmp.back(); tmp.pop_back(); C.insert(u); if(pu >= 0) ST.insert(make_pair(pu,u)); else su = u; pu = u; if(u == s) break; } ST.insert(make_pair(s,su)); for(int r : C) dfs2(r,-1,0); for(int i = 0;i < N;i++) { int u = A[i],v = B[i]; if(C.count(u) && C.count(v)) { if(ST.count(make_pair(u,v))) cout << "->\n"; else { assert(ST.count(make_pair(v,u))); cout << "<-\n"; } } else { if(depth[u] < depth[v]) cout << "<-\n"; else cout << "->\n"; } } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); //tanosimu int tt = 1; //cin >> tt; while(tt--) solve(); }