#include using namespace std; #define rep(i,n) for(int i = 0; i < (n); i++) typedef long long ll; typedef long double ld; typedef pair P; int main() { int n; cin >> n; vector> g(n); map id; rep(i,n) { int a, b; cin >> a >> b; a--; b--; id[make_pair(a, b)] = i + 1; id[make_pair(b, a)] = i + 1; g[a].emplace_back(b); g[b].emplace_back(a); } vector edge; vector visited(n, 0); auto dfs = [&](auto& f, int p, int u)->int{ if (visited[u]) { visited[u] = -1; return 0; } visited[u] = 1; for (auto v : g[u]) { if (v == p) continue; int ok = f(f, u, v); if (ok == 0) { edge.emplace_back(id[make_pair(u, v)]); if (visited[u] == -1) return -1; return 0; } if (ok == -1) return -1; } return 1; }; dfs(dfs,-1,0); cout << edge.size() << endl; for (auto e : edge) cout << e << " "; cout << endl; return 0; }