#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(unsigned int n) { if (n >= 100000) *outptr++ = '0' + n / 100000; if (n >= 10000) *outptr++ = '0' + n / 10000 % 10; if (n >= 1000) *outptr++ = '0' + n / 1000 % 10; if (n >= 100) *outptr++ = '0' + n / 100 % 10; if (n >= 10) *outptr++ = '0' + n / 10 % 10; *outptr++ = '0' + n % 10; } } 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((unsigned int) res.size()); fastio.put('\n'); for (int i = 0; i < (int) res.size(); i++) { if (i) fastio.put(' '); fastio.put((unsigned int) res[i] + 1); } fastio.put('\n'); return 0; }