#include using namespace std; int main(){ int n,m,k; cin >> n >> m >> k; vector > > g(n); for(int i=0;i> a >> b >> c; --a; --b; g[a][c].push_back(b); g[b][c].push_back(a); } vector ds(k); for(int i=0;i> ds[i]; set xs; for(int i=0;i ys; for (int x : xs){ if(g[x].count(d)){ for (int y : g[x][d]){ ys.insert(y); } } } xs = ys; } cout << xs.size() << endl; for(int x : xs) cout << x + 1 << ' '; cout << endl; return 0; }