#include int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); std::vector > hen[n]; for (int i = 0; i < n; i++) { int a = ri() - 1; int b = ri() - 1; hen[a].push_back({b, i}); hen[b].push_back({a, i}); } int degree[n]; for (int i = 0; i < n; i++) degree[i] = hen[i].size(); bool ok[n]; for (auto &i : ok) i = true; std::queue que; for (int i = 0; i < n; i++) if (degree[i] == 1) que.push(i); while (que.size()) { int i = que.front(); que.pop(); degree[i] = 0; for (auto j : hen[i]) { ok[j.second] = false; if (degree[j.first] && --degree[j.first] == 1) que.push(j.first); } } std::vector res; for (int i = 0; i < n; i++) if (ok[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; }