#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <time.h>

using namespace std;

vector<vector<pair<int, int> > > g;
vector<int> used;
vector<int> in;
long long ans = 1e18;
long long cur = 0;
int t = 0;

void dfs(int v, long long d)
{
	used[v] = t;
	cur += d * d;
	if (ans < cur) return;
	for (size_t i = 0; i < g[v].size(); ++i)
	{
		int u = g[v][i].first, c = g[v][i].second;
		if (used[u] < t) dfs(u, d + c);
	}
	return;
}

int main()
{
	freopen("bfs.in", "r", stdin);
	freopen("bfs.out", "w", stdout);
	int n;
	cin >> n;
	srand(time(0));
	g.resize(n);
	in.resize(n);
	for (int i = 0; i < n - 1; ++i)
	{
		int a, b, c;
		cin >> a >> b >> c;
		--a, --b, ++in[a], ++in[b];
		g[a].push_back(make_pair(b, c));
		g[b].push_back(make_pair(a, c));
	}
	vector<int> st;
	for (int i = 0; i < n; i++)
		if (in[i] > 1 || n < 20000) st.push_back(i);
	
	random_shuffle(st.begin(), st.end());
	vector<int> answer(10);
	int be = 0;
	used.assign(n, 0);
	int step = min((int)st.size(), (int)1e8 / n);
	for (int i = 0; i < step; ++i)
	{
		cur = 0;
		++t;
		dfs(st[i], 0);
		if (ans > cur)
		{
			ans = cur;
			be = 0;
			answer[be++] = st[i];
			continue;
		}
		if (ans == cur) answer[be++] = st[i];
	}
	cout << be << endl;
	for (int i = 0; i < be; ++i)
		cout << answer[i] + 1 << " ";
}
