#include #define rep(i,n) for (int i = 0; i < (n); ++i) #define chmax(a, b) a = max(a, b) #define chmin(a, b) a = min(a, b) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using P = pair; using VI = vector; using VVI = vector; VVI to; int n; map bmap; VI parent, depth; vector ans; bool dfs(int u, int d=0, int p=-1) { parent[u] = p; depth[u] = d; for(int v: to[u]) { if (v == p) continue; if (depth[v] == -1) { if (dfs(v, d+1, u)) return true;; } else { ans.push_back(bmap[{u, v}]); while(u != v) { if (depth[u] >= depth[v]) { ans.push_back(bmap[{u, parent[u]}]); u = parent[u]; } else { ans.push_back(bmap[{v, parent[v]}]); v = parent[v]; } } return true; } } return false; } int main() { cin >> n; to = VVI(n); depth = VI(n, -1); parent = VI(n, -1); rep(i, n) { int a, b; cin >> a >> b; a--; b--; bmap[{a, b}] = bmap[{b, a}] = i + 1; to[a].push_back(b); to[b].push_back(a); } dfs(0); sort(all(ans)); cout << ans.size() << endl; rep(i, ans.size()) cout << ans[i] << " \n"[i + 1 == ans.size()]; }