using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var map = NMap(n); var tree = new List<(int to, int id)>[n]; for (var i = 0; i < tree.Length; ++i) tree[i] = new List<(int to, int id)>(); for (var i = 0; i < map.Length; ++i) { tree[map[i][0]].Add((map[i][1], i)); tree[map[i][1]].Add((map[i][0], i)); } var loop = new List(); var visited = new bool[n]; for (var i = 0; i < n; ++i) { loop = new List(); if (!visited[i]) { if (DFS(-1, i, tree, visited, loop)) break; } } visited = new bool[n]; var ans = new bool[n]; var q = new Queue(); for (var i = 0; i < loop.Count; ++i) { var f = loop[i]; var t = loop[(i + 1) % loop.Count]; foreach (var edge in tree[f]) { if (edge.to == t) { if (map[edge.id][0] == t) ans[edge.id] = true; } } q.Enqueue(f); visited[f] = true; } while (q.Count > 0) { var cur = q.Dequeue(); foreach (var edge in tree[cur]) { if (!visited[edge.to]) { if (map[edge.id][0] == edge.to) ans[edge.id] = true; q.Enqueue(edge.to); visited[edge.to] = true; } } } WriteLine(string.Join("\n", ans.Select(f => f ? "->" : "<-"))); } static bool DFS(int prev, int cur, List<(int to, int id)>[] tree, bool[] visited, List loop) { if (visited[cur]) { var nl = new List(); for (var i = loop.Count - 1; i >= 0; --i) { nl.Add(loop[i]); if (loop[i] == cur) break; } loop.Clear(); foreach (var li in nl) loop.Add(li); return true; } visited[cur] = true; loop.Add(cur); foreach (var next in tree[cur]) { if (prev == next.to) continue; if (DFS(cur, next.to, tree, visited, loop)) return true; } loop.RemoveAt(loop.Count - 1); visited[cur] = false; return false; } }