#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a par, siz; UnionFind(int N) : par(N), siz(N,1){ rep(i,N) par[i] = i; } int root(int x){ if(par[x]==x) return x; return par[x] = root(par[x]); } bool unite(int x,int y){ x = root(x); y = root(y); if(x==y) return false; if(siz[x]>& g, vector& b){ for(auto& e:g[now]){ if(e.to==par) continue; b[e.num] = e.re; dfs(now, e.to, g, b); } } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; UnionFind uf(n); int x,num; vector> g(n); rep(i,n){ int a,b; cin >> a >> b; a--; b--; if(uf.unite(a,b)){ g[a].push_back({b,(int)i,0}); g[b].push_back({a,(int)i,1}); }else x = a, num = i; } vector b(n,false); dfs(-1,x,g,b); b[num] = true; rep(i,n) cout << (b[i]?"->\n":"<-\n"); return 0; }