#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { int N; cin >> N; vector> g(N); vector A(N), B(N); REP(i, N) { scanf("%d %d", &A[i], &B[i]); --A[i]; --B[i]; g[A[i]].emplace_back(B[i]); g[B[i]].emplace_back(A[i]); } vector ord(N, -1), low(N); auto dfs = [&](auto self, int u, int par, int & num) -> int { ord[u] = low[u] = num++; for (int v : g[u]) { if (v == par) continue; if (ord[v] == -1) { ord[v] = ord[u] + 1; chmin(low[u], self(self, v, u, num)); } else chmin(low[u], ord[v]); } return low[u]; }; int num = 0; dfs(dfs, 0, -1, num); vector ans; REP(i, N) { if (ord[A[i]] > ord[B[i]]) swap(A[i], B[i]); if (ord[A[i]] >= low[B[i]]) ans.emplace_back(i); } cout << ans.size() << endl; REP(i, ans.size()) printf("%d%c", ans[i] + 1, " \n"[i + 1 == ans.size()]); }