#define _USE_MATH_DEFINES #pragma GCC target("avx2") #pragma GCC optimize("O3") #define _USE_MATH_DEFINES #include #include #include #include #include using namespace std; #define LP(I,S,G) for (long long int I = (S); I < (G); ++I) #define IN(X) for (int in = 0; in < X.size(); in++)cin >> X[in] #define OUT(X) for (int in = 0; in < X.size(); in++)cout << X[in]<<" " #define SORT(X) sort((X).begin(), (X).end()) #define CSORT(X,Y) sort(X.begin(), X.end(),Y) #define COPY(X,Y) copy(X.begin(), X.end(), Y.begin()) #define ALL(X,Y) for (auto X = (Y).begin(); X != (Y).end(); X++) #define FULL(a) (a).begin(),(a).end() #define BFS(Q,S) for(Q.push(S);Q.size()!=0;Q.pop()) typedef long long int ll; typedef unsigned long long int ull; long long int M = 998244353; int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 }; ll MAX(ll A, ll B) { return ((A) > (B) ? (A) : (B)); } ll MIN(ll A, ll B) { return ((A) < (B) ? (A) : (B)); } inline long long int xor128() { static long long int x = 123456789, y = 362436069, z = 521288629, w = 88675123; long long int t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } ll dfs(ll now, ll past, vector>& g, vector& v, vector& c) { v[now] = 1; ll ret = -1; ALL(i, g[now]) { if (*i == past)continue; if (v[*i] == 1) { c[now] = 1; if (ret == -1)ret = *i; } else { ll res = MAX(ret, dfs(*i, now, g, v, c)); if (res != -1)ret = res; if (ret != -1)c[now] = 1; } } if (ret == now)ret = -1; return ret; } int main() { ll n; cin >> n; vector u(n), v(n); vector ans(n, 0); vector> g(n),G(n); vector vis(n, 0), c(n, 0); LP(i, 0, n) { cin >> u[i] >> v[i]; u[i]--, v[i]--; g[u[i]].push_back(i); g[v[i]].push_back(i); G[u[i]].push_back(v[i]); G[v[i]].push_back(u[i]); } dfs(0, -1, G, vis, c); queue q; LP(i, 0, n) { if (g[i].size() == 1)q.push(i); } while (q.size() != 0) { ll now = q.front(); q.pop(); ALL(i, g[now]) { ll gu = u[*i], gv = v[*i]; ll d = 1; if (gv == now) { swap(gu, gv); d *= -1; } if (ans[*i] == 0) { ans[*i] = d; if (c[gv]!=1)q.push(gv); } } } LP(i, 0, n) { if (ans[i] == 0) { ans[i] = 1; q.push(v[i]); break; } } while (q.size() != 0) { ll now = q.front(); q.pop(); ALL(i, g[now]) { ll gu = u[*i], gv = v[*i]; ll d = 1; if (gv == now) { swap(gu, gv); d *= -1; } if (ans[*i] == 0) { ans[*i] = d; q.push(gv); } } } LP(i, 0, n)cout << ((ans[i] == 1) ? "->" : "<-")<<"\n"; return 0; }