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 
	/*	/ ﾌﾌ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ム
		/ )\⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀  Y
		(⠀⠀| ( ͡° ͜ʖ ͡°）⠀⌒(⠀ ノ
		(⠀ ﾉ⌒ Y ⌒ヽ-く __／
		| _⠀｡ノ| ノ｡ |/
		(⠀ー '_人`ー ﾉ
		⠀|\ ￣ _人'彡ﾉ
		⠀ )\⠀⠀ ｡⠀⠀ /
		⠀⠀(\⠀ #⠀ /
		⠀/⠀⠀⠀/ὣ====================D-
		/⠀⠀⠀/⠀ \ \⠀⠀\
		( (⠀)⠀⠀⠀⠀ ) ).⠀)
		(⠀⠀)⠀⠀⠀⠀⠀( | /
		|⠀ /⠀⠀⠀⠀⠀⠀ | /
		[_] ⠀⠀⠀⠀⠀[___]                     */
	// Main Code at the Bottom
	import java.util.*;
	import java.lang.*;
	import java.io.*;
	import java.math.BigInteger; 
	public class Main {
		//Fast IO class
	    static class FastReader {
	        BufferedReader br; 
	        StringTokenizer st; 
	        public FastReader() {
	        	boolean env=System.getProperty("ONLINE_JUDGE") != null;
	        	if(!env) {
	        		try {
						br=new BufferedReader(new FileReader("src\\input.txt"));
					} catch (FileNotFoundException e) {
						e.printStackTrace();
					}
	        	}
	        	else br = new BufferedReader(new InputStreamReader(System.in)); 
	        } 
	        String next() {
	            while (st == null || !st.hasMoreElements()) {
	                try {
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) {
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken(); 
	        } 
	        int nextInt() {
	            return Integer.parseInt(next()); 
	        } 
	        long nextLong() {
	            return Long.parseLong(next()); 
	        } 
	        double nextDouble() {
	            return Double.parseDouble(next()); 
	        } 
	        String nextLine() {
	            String str = ""; 
	            try {
	                str = br.readLine(); 
	            } 
	            catch (IOException e) {
	                e.printStackTrace(); 
	            } 
	            return str; 
	        } 
	    }     
	    static long MOD=1000000000+7;
	    //Euclidean Algorithm
	    static long gcd(long A,long B){
	    	return (B==0)?A:gcd(B,A%B);
	    }
	    //Modular Exponentiation
	    static long fastExpo(long x,long n){
	        if(n==0) return 1;
	        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
	        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
	    }
	    //Modular Inverse
	    static long inverse(long x) {
	    	return fastExpo(x,MOD-2);
	    }
	    //Prime Number Algorithm
	    static boolean isPrime(long n){
	        if(n<=1) return false;
	        if(n<=3) return true;
	        if(n%2==0 || n%3==0) return false;
	        for(int i=5;i*i<=n;i+=6) if(n%i==0 || n%(i+2)==0) return false;
	        return true;
	    }
	    //Reverse an array
	    static void reverse(int arr[],int l,int r){
	    	while(l<r) {
	    		int tmp=arr[l];
	    		arr[l++]=arr[r];
	    		arr[r--]=tmp;
	    	}
	    }
	    //Print array
	    static void print1d(int arr[]) {
	    	out.println(Arrays.toString(arr));
	    }
	    static void print2d(long arr[][]) {
	    	for(long a[]: arr) out.println(Arrays.toString(a));
	    }
	    // Pair
	    static class pair{
	    	int x,y;
	    	pair(int a,int b){
	    		this.x=a;
	    		this.y=b;
	    	}
	    	public boolean equals(Object obj) {
	    		if(obj == null || obj.getClass()!= this.getClass()) return false;
	            pair p = (pair) obj;
	            return (this.x==p.x && this.y==p.y);
	        }
	    	public int hashCode() {
	            return Objects.hash(x,y);
	        }
	    }
	    static FastReader sc=new FastReader();
	    static PrintWriter out=new PrintWriter(System.out);  
	    //Main function(The main code starts from here
	    static class node{
	    	int dest, weight;
	    	node(int d,int w){
	    		dest=d;
	    		weight=w;
	    	}
	    }
	    static int V,dp[],color[];
	    static ArrayList<node> graph[];
	    static void init(int n){
	        V=n;
	        graph=new ArrayList[V];
	        dp=new int[n];
	        color=new int[n];
	        for(int i=0;i<V;i++) graph[i]=new ArrayList<>();
	    }
	    static void addEdge(int src,int dest,int weight){
	        graph[src].add(new node(dest,weight));
	        graph[dest].add(new node(src,weight));
	    }
	    static void dfs1(int s,int p) {
	    	for(node x: graph[s]) {
	    		if(x.dest==p) continue;
	    		if(x.weight==1) color[s]=color[x.dest]=1;
	    		dfs1(x.dest,s);
	    	}
	    }
	    static void dfs2(int s,int p) {
	    	dp[s]=color[s];
	    	for(node x: graph[s]) {
	    		if(x.dest==p) continue;
	    		dfs2(x.dest,s);
	    		dp[s]+=dp[x.dest];
	    	}
	    }
	    public static void main (String[] args) throws java.lang.Exception {
	    	int test;
	    	test=1;
	    	//test=sc.nextInt();
	    	while(test-->0){
	    		int n=sc.nextInt();
	    		init(n);
	    		for(int i=0;i<n-1;i++) addEdge(sc.nextInt()-1,sc.nextInt()-1,sc.nextInt()-1);
	    		dfs1(0,-1);
	    		dfs2(0,-1);
	    		ArrayList<Integer> ans=new ArrayList<>();
	    		for(int i=0;i<n;i++) if(color[i]==1 && dp[i]==1) ans.add(i+1);
	    		out.println(ans.size());
	    		for(Integer x: ans) out.print(x+" ");
	    	}
	        out.flush();
	        out.close();
	    }
	}