#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; vector> g(n); map, int> edge_id; for (int i = 0; i < n; i++) { int u, v; cin >> u >> v; u--, v--; g[u].insert(v); g[v].insert(u); edge_id[{u, v}] = edge_id[{v, u}] = i + 1; } deque q; for (int i = 0; i < n; i++) { if (g[i].size() == 1) { q.push_back(i); } } while (!q.empty()) { int u = q.front(); q.pop_front(); for (int v : g[u]) { g[v].erase(u); if (g[v].size() == 1) { q.push_back(v); } } g[u].clear(); } vector ans; for (int i = 0; i < n; i++) { for (int v : g[i]) { ans.push_back(edge_id[{i, v}]); } } sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); cout << ans.size() << "\n"; for (int i = 0; i < ans.size(); i++) { cout << ans[i] << " "; } cout << endl; }