#include int ri() { int n; scanf("%d", &n); return n; } std::vector > hen; std::vector used; std::vector stack; std::vector inloop; void dfs(int i, int prev) { used[i] = true; stack.push_back(i); for (auto j : hen[i]) { if (!used[j]) dfs(j, i); else if (j != prev) { for (int k = stack.size(); k--; ) { inloop[stack[k]] = true; if (stack[k] == j) break; } } } stack.pop_back(); } int main() { int n = ri(); hen.resize(n); int a[n], b[n]; for (int i = 0; i < n; i++) { a[i] = ri() - 1; b[i] = ri() - 1; hen[a[i]].push_back(b[i]); hen[b[i]].push_back(a[i]); } used.resize(n); inloop.resize(n); dfs(0, -1); std::vector res; for (int i = 0; i < n; i++) if (inloop[a[i]] && inloop[b[i]]) res.push_back(i); printf("%d\n", (int) res.size()); for (int i = 0; i < (int) res.size(); i++) { if (i) printf(" "); printf("%d", res[i] + 1); } puts(""); return 0; }