#include #include #include #include #include #include #include #include #include #include #include using namespace::std; int find_cycle(int n, const vector>& e) { vector visited(n + 1); vector> q; for (int i = 1; i <= n; ++i) if (!visited[i]) { q.push_back({-1, i}); while (!q.empty()) { auto [u, v] = q.back(); q.pop_back(); if (visited[v]) return v; visited[v] = 1; for (int w : e[v]) if (w != u) q.push_back({v, w}); } } return -1; } int main() { ios::sync_with_stdio(false); long long n; cin >> n; vector> input; vector> e(n + 1); for (int i = 0; i < n; ++i) { int a, b; cin >> a >> b; input.push_back({a, b}); e[a].push_back(b); e[b].push_back(a); } int c = find_cycle(n, e); vector p(n + 1); vector> q {{0, c}}; while (!q.empty()) { auto [u, v] = q.back(); q.pop_back(); if (p[v]) continue; p[v] = u; for (int w : e[v]) q.push_back({v, w}); } for (const auto [a, b] : input) cout << (p[a] == b ? "->" : "<-") << endl; return 0; }