# N頂点N辺グラフは1閉路を含むので、閉路になるまでは1方向、そこから1周させればいい # 次数0の点があれば、そこから閉路まで閉路方向 # 次数0の点がなければ、ただ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 degone = [] for i in range(1, N+1): if degree[i] == 1: degone.append(i) # まず閉路を確定させる from collections import deque que = deque() for v in degone: 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) circuit_set = set(circuit) que2 = deque() for v in degone: for i in range(N): a, b = edge_list[i] if a == v: last = a start = b que2.append((start, last)) break elif b == v: last = b start = a que2.append((start, last)) break #print('que2', que2) ans_list = [0]*(N+1) while que2: current, prev = que2.popleft() #print('current', current, 'prev', prev) if (current, prev) in edge_dic: if ans_list[edge_dic[(current, prev)]] == 0: ans_list[edge_dic[(current, prev)]] = -1 else: pass elif (prev, current) in edge_dic: if ans_list[edge_dic[(prev, current)]] == 0: ans_list[edge_dic[(prev, current)]] = +1 else: pass if current not in circuit: for nxt in edges[current]: if nxt != prev: que2.append((nxt, current)) # 今度は閉路の辺に方向を付ける que3 = deque() for i in range(N): a, b = edge_list[i] # ここでWAした、a, b両方とも閉路上が必要 if a in circuit_set and b in circuit_set: if a == circuit[0]: last = a start = b que3.append((start, last)) break elif b == circuit[0]: last = b start = a que3.append((start, last)) break #print(que3) while que3: current, prev = que3.popleft() #print('current', current, 'prev', prev) if (current, prev) in edge_dic: if ans_list[edge_dic[(current, prev)]] == 0: ans_list[edge_dic[(current, prev)]] = -1 else: break elif (prev, current) in edge_dic: if ans_list[edge_dic[(prev, current)]] == 0: ans_list[edge_dic[(prev, current)]] = +1 else: break for nxt in edges[current]: if nxt != prev and nxt in circuit: que3.append((nxt, current)) #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')