from collections import defaultdict, deque def lowlink(n, adj): bridges = [] articulation_points = [] used = [False] * n order = [0] * n low = [0] * n def dfs(now, parent, count): used[now] = True order[now] = count low[now] = order[now] count += 1 isarticulation = False # 間接点か nchildren = 0 for to in adj[now]: if used[to]: # 訪問済みの頂点 = 後退辺 if to != parent: low[now] = min(low[now], order[to]) else: nchildren += 1 count = dfs(to, now, count) if to != parent: low[now] = min(low[now], low[to]) if parent != -1 and order[now] <= low[to]: isarticulation = True if order[now] < low[to]: bridges.append((now, to)) if parent == -1 and nchildren >= 2: isarticulation = True if isarticulation: articulation_points.append(now) return count count = 0 for i in range(n): if used[i]: continue count = dfs(i, -1, count) return bridges, articulation_points N = int(input()) edge2id = {} adj = defaultdict(list) for i in range(N): a, b = map(lambda x: int(x)-1, input().split()) adj[a].append(b) adj[b].append(a) edge2id[a, b] = i bridges, _ = lowlink(N, adj) bs = set(bridges) ans = [] for a, b in edge2id.keys(): if (a, b) in bs: continue if (b, a) in bs: continue ans.append(edge2id[a, b] + 1) print(len(ans)) print(*ans)