#include #include using namespace std; using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } vectorto[200005]; vectorcyid; bool dfs(int v, int c, int p = -1) { bool ret = false; if (v == c)ret = true; for (auto nv : to[v]) { if (p == nv) continue; if (dfs(nv, c, v)) { ret = true; } } if (ret)cyid.push_back(v); return ret; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector

ed(n); mapmp; rep(i, n) { int u, v; cin >> u >> v; u--, v--; ed[i] = { u,v }; mp[{u, v}] = { i,1 }; mp[{v, u}] = { i,-1 }; } vectorans(n, 0); setst; { // サイクルを取得する dsu uf(n); rep(i, n) { if (uf.same(ed[i].first, ed[i].second)) { if (cyid.empty())dfs(ed[i].first, ed[i].second); } else { uf.merge(ed[i].first, ed[i].second); } to[ed[i].first].emplace_back(ed[i].second); to[ed[i].second].emplace_back(ed[i].first); } rep(i, cyid.size()) { st.insert(cyid[i]); //cout << mp[{cyid[i], cyid[(i + 1) % cyid.size()]}].first << " " << mp[{cyid[i], cyid[(i + 1) % cyid.size()]}].second << endl; ans[mp[{cyid[i], cyid[(i + 1) % cyid.size()]}].first] = mp[{cyid[i], cyid[(i + 1) % cyid.size()]}].second; } } queueque; vectorcnt(n); rep(i, n) { cnt[i] = to[i].size(); if (1 == to[i].size()) { que.push(i); cnt[i] = 0;; } } while (!que.empty()) { int top = que.front(); que.pop(); if (st.count(top))break; cnt[top] = 0; rep(i, to[top].size()) { if (0 == cnt[to[top][i]])continue; que.push(to[top][i]); ans[mp[{to[top][i], top}].first] = mp[{to[top][i], top}].second; } } rep(i, n) { if (1 == ans[i])cout << "<-" << endl; else if(-1 == ans[i])cout << "->" << endl; } return 0; }