#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; using ull = unsigned long long; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; } //mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); constexpr long long INF = 1LL << 60; constexpr int inf = 1000000007; constexpr long long mod = 1000000007LL; //constexpr long long mod = 998244353; constexpr int MAX = 1100000; struct LowLink { int n, now_ord; vector> g; vector ord, low; vector used; LowLink(int n) :n(n), now_ord(0), g(n), ord(n, -1), low(n), used(n) {} void add_edge(int from, int to) { g[from].emplace_back(to); g[to].emplace_back(from); } void dfs(int cur, int pre) { ord[cur] = low[cur] = now_ord++; for (auto nxt : g[cur]) { if (nxt == pre) continue; if (ord[nxt] == -1) { dfs(nxt, cur); chmin(low[cur], low[nxt]); } else { chmin(low[cur], ord[nxt]); } } } void build() { for (int i = 0; i < n; i++) if (ord[i] == -1) dfs(i, -1); } bool isbridge(int u, int v) { if (ord[u] == -1) build(); if (ord[u] > ord[v]) swap(u, v); return ord[u] < low[v]; } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; LowLink lowlink(n); vector> edge; edge.reserve(n); for (int i = 0; i < n; i++) { int u, v; cin >> u >> v; u--; v--; lowlink.add_edge(u, v); edge.emplace_back(u, v, i + 1); } lowlink.build(); vector res; for (auto& [u, v, id] : edge) { if (!lowlink.isbridge(u, v)) res.emplace_back(id); } cout << res.size() << "\n"; for (int i = 0; i < res.size(); i++) cout << res[i] << " \n"[i + 1 == res.size()]; }