from collections import deque n = int(input()) g = [[] for _ in range(n)] edges = [] for _ in range(n): a, b = map(int, input().split()) a -= 1 b -= 1 g[a].append(b) g[b].append(a) edges.append((a, b)) dq = deque() deg = [len(g[v]) for v in range(n)] used = [False for _ in range(n)] for v in range(n): if deg[v] == 1: deg[v] -= 1 used[v] = True dq.appendleft(v) while len(dq) > 0: cur = dq.pop() for nxt in g[cur]: if used[nxt]: continue deg[nxt] -= 1 if deg[nxt] == 1: deg[nxt] -= 1 used[nxt] = True dq.appendleft(nxt) print(used) ans = [] for i in range(len(edges)): a, b = edges[i] if not used[a] and not used[b]: ans.append(i + 1) print(len(ans)) print(*ans, sep=" ")