#pragma GCC optimize("Ofast") #include using namespace std; typedef long long int ll; typedef unsigned long long int ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast(chrono::duration_cast(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector x(n),y(n); vector> g(n); vector deg(n); for (int i = 0; i < n; ++i) { cin >> x[i] >> y[i]; x[i]--; y[i]--; g[x[i]].push_back(y[i]); g[y[i]].push_back(x[i]); deg[x[i]]++; deg[y[i]]++; } vector uo(n, -1); queue q; for (int i = 0; i < n; ++i) { if (deg[i] == 1) { q.push(i); } } set> st; while (q.size()) { int s = q.front(); q.pop(); for (int t:g[s]) { if (st.find({s, t}) == st.end()) { uo[s] = t; st.insert({s,t}); st.insert({t,s}); deg[t]--; if (deg[t] == 1 and uo[t] == -1) { q.push(t); } } } } for (int i = 0; i < n; ++i) { if (uo[i] == -1) { int s = i; while (1) { for (int t:g[s]) { if (st.find({s, t}) == st.end()) { uo[s] = t; st.insert({s,t}); st.insert({t,s}); s = t; break; } } if (uo[s] != -1) break; } } } for (int i = 0; i < n; ++i) { if (uo[x[i]] == y[i]) { cout << "->" << "\n"; } else { cout << "<-" << "\n"; } } }