#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 1000000007; // constexpr int MOD = 998244353; constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); } } iosetup; template struct Edge { int src, dst; CostType cost; Edge(int src, int dst, CostType cost = 0) : src(src), dst(dst), cost(cost) {} inline bool operator<(const Edge &x) const { return cost != x.cost ? cost < x.cost : dst != x.dst ? dst < x.dst : src < x.src; } inline bool operator<=(const Edge &x) const { return !(x < *this); } inline bool operator>(const Edge &x) const { return x < *this; } inline bool operator>=(const Edge &x) const { return !(*this < x); } }; template struct Lowlink { using E = Edge; std::vector> graph; std::vector ap; std::vector bridge; Lowlink(const std::vector> &graph) : graph(graph) { int n = graph.size(); order.assign(n, -1); lowlink.resize(n); int tm = 0; for (int i = 0; i < n; ++i) { if (order[i] == -1) dfs(-1, i, tm); } // std::sort(ap.begin(), ap.end()); // std::sort(bridge.begin(), bridge.end(), [](const E &a, const E &b) -> bool { // return a.src != b.src ? a.src < b.src : a.dst != b.dst ? a.dst < b.dst : a.cost < b.cost; // }); } std::vector order, lowlink; private: void dfs(int par, int ver, int &tm) { order[ver] = lowlink[ver] = tm++; int cnt = 0; bool is_ap = false; for (const E &e : graph[ver]) { if (order[e.dst] == -1) { ++cnt; dfs(ver, e.dst, tm); if (lowlink[e.dst] < lowlink[ver]) lowlink[ver] = lowlink[e.dst]; if (order[ver] <= lowlink[e.dst]) { is_ap = true; if (order[ver] < lowlink[e.dst]) bridge.emplace_back(std::min(ver, e.dst), std::max(ver, e.dst), e.cost); } } else if (e.dst != par) { if (order[e.dst] < lowlink[ver]) lowlink[ver] = order[e.dst]; } } if (par == -1) { if (cnt >= 2) ap.emplace_back(ver); } else { if (is_ap) ap.emplace_back(ver); } } }; int main() { int n; cin >> n; vector>> graph(n); map, int> mp; REP(i, n) { int a, b; cin >> a >> b; --a; --b; if (a > b) swap(a, b); mp[{a, b}] = i; graph[a].emplace_back(a, b); graph[b].emplace_back(b, a); } set st; REP(i, n) st.emplace(i); for (auto &e : Lowlink(graph).bridge) { int p = e.src, q = e.dst; if (p > q) swap(p, q); st.erase(mp[{p, q}]); } vector ans(st.begin(), st.end()); int k = ans.size(); cout << k << '\n'; REP(i, k) cout << ans[i] + 1 << " \n"[i + 1 == k]; return 0; }