import sys input = sys.stdin.readline from collections import deque class UnDirectedGraph: def __init__(self, N): self.V = N self.edge = [[] for _ in range(self.V)] self.edges = [0]*N self.edge_tf = [False]*N self.visited = [False]*N self.parent = [N]*N self.order = [-1]*N self.low = [-1]*N def add_edges(self, M): for i in range(M): a,b = map(int, input().split()) self.edge[a-1].append((b-1,i)) self.edge[b-1].append((a-1,i)) self.edges[i] = (a-1,b-1) def add_edge(self, a, b): self.edge[a].append(b) self.edge[b].append(a) def dfs(self, start): stack = deque([start]) self.parent[start] = -1 #記録したい値の配列を定義 self.order[start] = 0 cnt = 1 while stack: v = stack[-1] for u,i in self.edge[v]: if u==self.parent[v]: continue if self.parent[u]==N: #行き self.parent[u]=v stack.append(u) self.order[u] = cnt self.edge_tf[i] = True cnt += 1 break else: stack.pop() #帰り return def dfs2(self, start): stack = deque([start]) self.visited[start] = True #記録したい値の配列を定義 self.low0 = self.order[:] self.low1 = self.order[:] while stack: v = stack[-1] for u,i in self.edge[v]: if self.edge_tf[i] and self.order[v]>self.order[u]: continue if self.visited[u]==False: #行き self.visited[u]=True stack.append(u) break else: if self.edge_tf[i]: self.low0[v] = min(self.low0[v], self.low0[u]) self.low1[v] = min(self.low1[v], self.low1[u]) else: self.low1[v] = min(self.low1[v], self.low0[u]) else: stack.pop() #帰り return def bfs(self, start): d = deque() self.visited[start]=True d.append((start,cnt)) while len(d)>0: v,cnt = d.popleft() for w in self.edge[v]: if self.visited[w]==False: self.visited[w]=True d.append((w,cnt+1)) return cnt N = int(input()) G = UnDirectedGraph(N) G.add_edges(N) G.dfs(0) G.dfs2(0) ans = [] for i,(a,b) in enumerate(G.edges): if G.edge_tf[i]==False: ans.append(i+1) continue if G.order[a]>G.order[b]: a,b = b,a if G.low1[b]<=G.order[a]: ans.append(i+1) print(len(ans)) print(*ans)