import std.conv, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; } int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); } int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); } int N; int[] A, B; int[][] G; int[] par; int[] dp, DP; void dfs(int u, int p) { par[u] = p; foreach (v; G[u]) { if (v != p) { dfs(v, u); } } int sum; foreach (v; G[u]) { if (v != p) { sum += dp[v]; } } dp[u] = (sum == 0) ? 1 : 0; } void DFS(int u, int p) { int sum; foreach (v; G[u]) { if (v != p) { sum += dp[v]; } } if (p != -1) { sum += DP[u]; } foreach (v; G[u]) { if (v != p) { debug { writefln("%s -> %s: %s", v, u, sum - dp[v]); } DP[v] = (sum - dp[v] == 0) ? 1 : 0; } } foreach (v; G[u]) { if (v != p) { DFS(v, u); } } } void main() { try { for (; ; ) { N = readInt(); A = new int[N - 1]; B = new int[N - 1]; foreach (i; 0 .. N - 1) { A[i] = readInt() - 1; B[i] = readInt() - 1; } G = new int[][N]; foreach (i; 0 .. N - 1) { G[A[i]] ~= B[i]; G[B[i]] ~= A[i]; } par = new int[N]; dp = new int[N]; DP = new int[N]; const rt = 0; dfs(rt, -1); DFS(rt, -1); debug { writeln("rt = ", rt); writeln("dp = ", dp); writeln("DP = ", DP); } int[] ans; foreach (u; 0 .. N) { int sum; foreach (v; G[u]) { if (v != par[u]) { sum += dp[v]; } } if (u != rt) { sum += DP[u]; } if (sum == 0) { ans ~= u; } } writeln(ans.length); foreach (u; ans) { writeln(u + 1); } } } catch (EOFException e) { } }