#include struct FastIO { char inbuf[1500000]; char outbuf[800000]; char *inptr = inbuf; char *outptr = outbuf; void read() { int size = fread(inbuf, 1, sizeof(inbuf) - 1, stdin); inbuf[size] = '\0'; inptr = inbuf; } FastIO () { read(); } ~FastIO() { fwrite(outbuf, 1, outptr - outbuf, stdout); } template Integer read() { bool neg = false; Integer res = 0; while ((*inptr < '0' || *inptr > '9') && *inptr != '-') inptr++; if (*inptr == '-') neg = true, inptr++; while (*inptr >= '0' && *inptr <= '9') res = res * 10 + *inptr - '0', inptr++; return neg ? -res : res; } void put(char c) { *outptr++ = c; } void put(int n) { static char tmp[10]; if (!n) { put('0'); return; } if (n < 0) n = -n, put('-'); char *tmpptr = tmp; while (n) *tmpptr++ = n % 10 + '0', n /= 10; while (tmpptr != tmp) *outptr++ = *--tmpptr; } } fastio; #define ri fastio.read #define rs64 fastio.read int main() { int n = ri(); std::vector > hen[n]; for (int i = 0; i < n; i++) { int a = ri() - 1; int b = ri() - 1; hen[a].push_back({b, i}); hen[b].push_back({a, i}); } int degree[n]; for (int i = 0; i < n; i++) degree[i] = hen[i].size(); bool ok[n]; for (auto &i : ok) i = true; std::queue que; for (int i = 0; i < n; i++) if (degree[i] == 1) que.push(i); while (que.size()) { int i = que.front(); que.pop(); degree[i] = 0; for (auto j : hen[i]) { ok[j.second] = false; if (degree[j.first] && --degree[j.first] == 1) que.push(j.first); } } std::vector res; for (int i = 0; i < n; i++) if (ok[i]) res.push_back(i); fastio.put((int) res.size()); fastio.put('\n'); for (int i = 0; i < (int) res.size(); i++) { if (i) fastio.put(' '); fastio.put(res[i] + 1); } fastio.put('\n'); return 0; }