print("reference: maspy")

N, U, V = map(int, input().split())

graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
  a, b = map(int, input().split())
  graph[a].append(b)
  graph[b].append(a)

# maspyさんのおかげで、dfsとbfsが一貫して組めている。
def dfs(v): # dfsやbfsはgcdやroot_find、mergeと同様のものと考える。	
    dist = [-1] * (N + 1)
    stack = [v]
    dist[v] = 0
    while stack:
        v = stack.pop()
        for w in graph[v]:
            if dist[w] != -1:
                continue
            dist[w] = dist[v] + 1
            stack.append(w)
    return dist

DU = dfs(U) # Takahashi
DV = dfs(V) # Aoki
print(DU)
print(DV)
 
answer = []
for i  in range(1, N + 1):
  if DU[i] < DV[i]:
    answer.append(DV[i] - 1)

print(answer)