The city Valera lives in is going to hold elections to the city Parliament.

The city has n districts and n - 1 bidirectional roads. We know that from any district there is a path along the roads to any other district. Let's enumerate all districts in some way by integers from 1 to n, inclusive. Furthermore, for each road the residents decided if it is the problem road or not. A problem road is a road that needs to be repaired.

There are n candidates running the elections. Let's enumerate all candidates in some way by integers from 1 to n, inclusive. If the candidate number i will be elected in the city Parliament, he will perform exactly one promise — to repair all problem roads on the way from the i-th district to the district 1, where the city Parliament is located.

Help Valera and determine the subset of candidates such that if all candidates from the subset will be elected to the city Parliament, all problem roads in the city will be repaired. If there are several such subsets, you should choose the subset consisting of the minimum number of candidates.

Input

The first line contains a single integer n (2 ≤ n ≤ 105) — the number of districts in the city.

Then n - 1 lines follow. Each line contains the description of a city road as three positive integers xi, yi, ti (1 ≤ xi, yi ≤ n, 1 ≤ ti ≤ 2) — the districts connected by the i-th bidirectional road and the road type. If ti equals to one, then the i-th road isn't the problem road; if ti equals to two, then the i-th road is the problem road.

It's guaranteed that the graph structure of the city is a tree.

Output

In the first line print a single non-negative number k — the minimum size of the required subset of candidates. Then on the second line print k space-separated integers a1, a2, ... ak — the numbers of the candidates that form the required subset. If there are multiple solutions, you are allowed to print any of them.

Examples

Input

5
1 2 2
2 3 2
3 4 2
4 5 2


Output

1
5 


Input

5
1 2 1
2 3 2
2 4 1
4 5 1


Output

1
3 


Input

5
1 2 2
1 3 2
1 4 2
1 5 2


Output

4
5 4 3 2 
/*
    Date         :
    Problem Name :
    Location     :
    Algorithm    :
    Status       :
    CodingTime   :
    ReadingTime  :
*/

import java.util.*;
import java.io.*;
public class Main {
    static BufferedReader reader 
		= new BufferedReader(new InputStreamReader(System.in));       
    static class Road{
        int to;
        boolean problem;
        public Road(int to, boolean problem){
            this.to = to;
            this.problem = problem;
        }
    }

    // map.get(i) is the collection of 
    // Roads from node i
    static ArrayList<ArrayList<Road>> map 
        = new ArrayList<ArrayList<Road>>(); 

    // shouldWin[i] = true 
    // iff city_i has a problem road to city_j
    // and city_i is the "furthest" city to have a problem road 

    static boolean[] shouldWin;
    public static void main(String[] args){
        int n = nextInt();
        for (int i = 0; i <= n; i++){
            map.add(new ArrayList<Road>());
        }
        for (int i = 0; i < n - 1; i++){
            int[] tmp = nextIntArray();
            map.get(tmp[0]).add(new Road(tmp[1], tmp[2] == 2));
            map.get(tmp[1]).add(new Road(tmp[0], tmp[2] == 2));
        }
        shouldWin = new boolean[n + 1]; // shouldWin[i] is whether candidate i should win
        dfs(1, -1);

        int cnt = 0; // counting the number of cities that need to win the election
        for (boolean b : shouldWin){
            if (b) cnt ++;
        }
        System.out.println(cnt);
        for (int i = 0; i < shouldWin.length; i++){
            if (shouldWin[i]) {
                System.out.print(i);
                cnt --;
                if (cnt > 0){
                    System.out.print(" ");
                }
            }
        }
        System.out.println("");


    }
    // updates the value of shouldWin 
    // return value tells whether node is already included in paths
    static boolean dfs(int city, int from){
        boolean isIncluded = false; // whether this "city" is going to be part of repair project.  for (Road road : map.get(city)){
        for (Road road : map.get(city)){
            if (road.to == from){
                continue;
            }
            if (dfs(road.to, city)){ // if city_{road.to} is alredy included
                isIncluded = true;
            } else if (road.problem){ // if city_{road.to} is not included, but the road b/w city and road.to is a problem road
                shouldWin[road.to] = true; // city_{road.to} should win
                isIncluded = true; // and the current city is already included
            }
        }

        return isIncluded;
    }

    static int nextInt(){
        return Integer.parseInt(nextLine());
    }
    static int[] nextIntArray(){
        String[] inp = nextLine().split("\\s+");
        int[] ary = new int[inp.length];
        for (int i = 0; i < ary.length; i++){
            ary[i] = Integer.parseInt(inp[i]);
        }
        return ary;
    }
	static String nextLine(){
		try { 
			return reader.readLine().trim();
		} catch (Exception e){}
		return null;
	}
}

