# N頂点N辺グラフは1閉路を含むので、閉路で1周、ひげは閉路向きとすればいい # 昨日は実装失敗した、閉路上で方向を付けるときのスタート確定で失敗した # 閉路確定したら、まず閉路内で方向を決めて # それから、閉路からひげの先に向かうべきだった # ひげの先から辿ると、閉路にたどり着く前の分岐で困ってしまう N = int(input()) edge_dic = {} edge_list = [] edges = [[] for i in range(N+1)] degree = [0]*(N+1) for i in range(N): a, b = map(int, input().split()) edge_list.append((a, b)) edge_dic[(a, b)] = i+1 edges[a].append(b) edges[b].append(a) degree[a] += 1 degree[b] += 1 degree1 = [] for i in range(1, N+1): if degree[i] == 1: degree1.append(i) # まず閉路を確定させる from collections import deque que = deque() for v in degree1: que.append((v, 0)) degree[v] -= 1 while que: current, prev = que.popleft() #print('current', current, 'prev', prev, degree) for nxt in edges[current]: if nxt != prev: degree[nxt] -= 1 if degree[nxt] == 1: que.append((nxt, current)) #print(degree) circuit = [] for i in range(1, N+1): if degree[i] >= 2: circuit.append(i) #print(circuit) # ひげの先からやると、ひげの中の枝分かれでどっちに行くかという問題ができてしまう # よって、閉路からひげの先に向かう方が確実だ # そのためにはまず閉路上の方向を決めて、それから閉路からひげに向かおう import sys sys.setrecursionlimit(10**7) def dfs1(current, prev): for nxt in edges[current]: if nxt != prev and nxt in circuit_set: if (nxt, current) in edge_dic: if ans_list[edge_dic[(nxt, current)]] == 0: ans_list[edge_dic[(nxt, current)]] = -1 dfs1(nxt, current) elif (current, nxt) in edge_dic: if ans_list[edge_dic[(current, nxt)]] == 0: ans_list[edge_dic[(current, nxt)]] = +1 dfs1(nxt, current) circuit_set = set(circuit) ans_list = [0]*(N+1) dfs1(circuit[0], 0) # 今度は閉路からひげに向かう def dfs2(current, prev): for nxt in edges[current]: if nxt != prev and nxt not in circuit_set: #print('current', current, 'prev', prev, 'nxt', nxt) #print((nxt, current) in edge_dic,(current, nxt) in edge_dic ) if (nxt, current) in edge_dic: if ans_list[edge_dic[(nxt, current)]] == 0: ans_list[edge_dic[(nxt, current)]] = +1 dfs2(nxt, current) elif (current, nxt) in edge_dic: #print(ans_list[edge_dic[(current, nxt)]] == 0) if ans_list[edge_dic[(current, nxt)]] == 0: ans_list[edge_dic[(current, nxt)]] = -1 dfs2(nxt, current) for v in circuit_set: dfs2(v, 0) #print(ans_list) for i in range(1, N+1): if ans_list[i] == 1: print('->') elif ans_list[i] == -1: print('<-') else: print('not determined')