n = int(input()) to = [[] for _ in range(n)] bmap = {} for i in range(1, n+1): a, b = map(int, input().split()) a -= 1 b -= 1 to[a].append(b) to[b].append(a) bmap[(a, b)] = bmap[(b, a)] = i num = [-1] * n low = [-1] * n visited = [False] * n ans = 0 nm = 1 def dfs(v, p=-1): global nm visited[v] = True num[v] = nm nm += 1 lw = num[v] for w in to[v]: if w == p: continue if not visited[w]: dfs(w, v) lw = min(lw, low[w]) else: lw = min(lw, num[w]) low[v] = lw dfs(0) ans = set(range(1, n+1)) visited = [False] * n def dfs2(v, p=-1): visited[v] = True for w in to[v]: if w == p: continue if not visited[w]: dfs2(w, v) if low[w] > num[v]: ans.remove(bmap[(v, w)]) dfs2(0) print(len(ans)) print(*ans)