#include #include using namespace std; using namespace atcoder; typedef int64_t lint; #define rep(i, n) for(int i=0; i; using vvi = vector>; template inline void vin(vector& v) { rep(i, v.size()) cin >> v.at(i); } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template inline void drop(T x) { cout << x << endl; exit(0); } template void vout(vector v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; } constexpr lint LINF = LLONG_MAX/2; vector> G; vi l, r; void make_graph(lint N, lint M) { G.resize(N); lint x, y; rep(i, M) { cin >> x >> y; x--, y--; l.pb(x), r.pb(y); G[x].push_back(y); G[y].push_back(x); } } vi topo_sort() { vi res; lint N = G.size(); vi v(N); rep(i, N) { for (auto e : G[i]) v[e]++; } queue Q; rep(i, N) { if (v[i] == 1) Q.push(i); } while (!Q.empty()) { int x = Q.front(); Q.pop(); res.push_back(x); for (auto e : G[x]) { v[e]--; if (v[e] == 1) Q.push(e); } } return res; } using pint = pair; using vp = vector; vector dist; void dfs(int root) { lint x, y, z, N = G.size(); dist.resize(N, -1); stack Q; Q.push({root, root}), dist[root] = -1; while (!Q.empty()) { tie(x, z) = Q.top(); Q.pop(); if (dist[x] != -1) continue; dist[x] = dist[z]+1; rep(i, G[x].size()) { y = G[x][i]; if (dist[y] == -1) Q.push({y, x}); } } } int main() { lint N; cin >> N; make_graph(N, N); lint a=0, b=0, c=0, x, y, z; vi v = topo_sort(); set s; rep(i, v.size()) s.insert(v[i]); rep(i, N) { if (!s.count(i)) { dfs(i); break; } } rep(i, N) { if (s.count(l[i])) { cout << "->" << endl; } else if (s.count(r[i])) { cout << "<-" << endl; } else { if (dist[l[i]]+1 == dist[r[i]]) { cout << "->" << endl; } else if (dist[l[i]] == dist[r[i]]+1) { cout << "<-" << endl; } else if (dist[l[i]] == 0) { cout << "<-" << endl; } else { cout << "->" << endl; } } } }