import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N = int(input()) G = [[] for _ in range(N)] for i in range(N): a, b = map(int, input().split()) a -= 1 b -= 1 G[a].append((b, i)) G[b].append((a, i)) bridge = [0] * N vis = [0] * N entry = [-1] * N low = [-1] * N time = 0 def dfs(s, p=-1): global time vis[s] = 1 entry[s] = time low[s] = time time += 1 for t, i in G[s]: if t == p: continue if vis[t]: low[s] = min(low[s], entry[t]) else: dfs(t, s) low[s] = min(low[s], low[t]) if entry[s] < low[t]: bridge[i] = 1 dfs(0) ans = [i for i, b in enumerate(bridge, 1) if b == 0] print(len(ans)) print(*ans)