#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))); } int main() { ll n; cin >> n; vector u(n), v(n); vector ans(n, 0); vector> g(n); 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); } 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 (g[gv].size() < 3)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; }