#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; using ll = long long; using P = pair; constexpr int INF = 1001001001; // constexpr int mod = 1000000007; constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector a(N), b(N); vector> graph(N); for(int i = 0; i < N; ++i){ cin >> a[i] >> b[i]; --a[i], --b[i]; graph[a[i]].emplace_back(b[i]); graph[b[i]].emplace_back(a[i]); } vector ans; for(int i = 0; i < N; ++i){ if(graph[a[i]].size() == 1 || graph[b[i]].size() == 1) continue; ans.emplace_back(i + 1); } int n = ans.size(); cout << n << '\n'; for(int i = 0; i < n; ++i){ cout << ans[i]; cout << ((i == n - 1) ? '\n' : ' '); } return 0; }