# 입력
import sys
n = int(sys.stdin.readline().strip())
graph = {}
for _ in range(n-1):
a,b = map(int, sys.stdin.readline().split())
if a in graph:
graph[a].append(b)
else:
graph[a] = [b]
if b in graph:
graph[b].append(a)
else:
graph[b] = [a]
visitedList = [False]*n
parent = {}
# 처리
def BFS(graph, node, visitedList):
from collections import deque
queue = deque([node])
visitedList[node-1] = True
while queue:
temp = queue.popleft()
for i in graph[temp]:
if not visitedList[i-1]:
queue.append(i)
visitedList[i-1] = True
parent[i] = temp
BFS(graph, 1, visitedList)
for i in sorted(parent.items()):
print(i[1])