import sys sys.setrecursionlimit(10 ** 9) input = sys.stdin.buffer.readline int1 = lambda x: int(x) - 1 def bridge(G, N): """ 橋検出 https://tjkendev.github.io/procon-library/python/graph/bridge.html より拝借しています。 networkxが使えないサイト用 """ result = set() label = [None] * N gen = 0 cost = [0] * N def dfs(u, p): nonlocal gen res = 0 for v in G[u]: if v == p: continue if label[v] is not None: if label[v] < label[u]: cost[v] += 1 res += 1 else: label[v] = gen gen += 1 r = dfs(v, u) if r == 0: result.add((u, v) if u < v else (v, u)) res += r res -= cost[u] return res for v in range(N): if not label[v]: label[v] = gen gen += 1 r = dfs(v, -1) # assert r == 0, r return result N = int(input()) G = [[] for _ in range(N)] AB = [tuple(sorted(list(map(int1, input().split())))) for _ in range(N)] for a, b in AB: G[a].append(b) G[b].append(a) res = bridge(G, N) ans = [] for i in range(N): if AB[i] not in res: ans.append(i + 1) print(len(ans)) print(*ans)