#include #include #include #include #include #include #include #include #include #include using namespace std; using ll = int64_t; #define rep(i, j, n) for (int i = j; i < (n); ++i) #define rrep(i, j, n) for (int i = (n)-1; j <= i; --i) int main() { int n, a, b; cin >> n; vector>> g(n); vector deg(n); rep(i, 0, n) { cin >> a >> b; --a, --b; g[a].insert({b, i}); g[b].insert({a, i}); deg[a]++; deg[b]++; } queue q; rep(i, 0, n) if (deg[i] == 1) q.push(i); set st; rep(i, 0, n) st.insert(i); while (!q.empty()) { int v = q.front(); q.pop(); auto [nv, idx] = *g[v].begin(); --deg[nv]; st.erase(idx); g[nv].erase({v, idx}); if (deg[nv] == 1) q.push(nv); } cout << st.size() << '\n'; for (auto itr = st.begin(); itr != st.end(); ++itr) cout << *itr + 1 << ' '; return 0; }