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 

import java.util.*;
import java.io.*;

public class C32 {
    public static long time = 0;
    public static void main(String[] args) throws Exception {
        time = System.currentTimeMillis();
        solve();
        out.flush();
    }
    static boolean[] cleanPoint = null;
    static boolean[] ex = null;
    static IntL fin = new IntL();
    static int[] weight = null;
    static IntL[] al = null;
    public static void solve() throws Exception {
        int n1 = ni();
        ex = new boolean[n1 + 10];
        weight = new int[n1 + 10];
        al = new IntL[n1];
        for (int i =0; i < n1; i++) al[i] = new IntL();
        cleanPoint = new boolean[n1];
        Arrays.fill(cleanPoint, true);
        
        for (int i =0; i < n1 - 1; i++){
            int x1 = ni() - 1;
            int y1 = ni() - 1;
            al[x1].add(y1);
            al[y1].add(x1);
            int t1 = ni();
            if (t1 == 2){
                cleanPoint[x1] = false;
                cleanPoint[y1] = false;
            }
        }
        weight(0,0);
        ex[0] = true;
//      px(weight);
        for (int i = 0; i < n1; i++){
            int sum  = 0;
            if (weight[i] == 1 && !cleanPoint[i]){
                fin.add(i);
            }
        }
        pn(fin.size);
        for (int e: fin){
            p(e+1+" ");
        }
        pn();
    }
    static int weight(int v1, int not){
        int fin = 0;
        for (int e: al[v1]){
            if (e == not) continue;
            fin += weight(e, v1);
//          px(weight(e, v1),e,v1);
        }
        weight[v1] = fin + (cleanPoint[v1] == true ? 0 : 1);
//      px(v1, weight[v1]);
        return weight[v1];
    }

    
    public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    public static StringTokenizer st = null;
    public static String nx() throws Exception {
        for (;st == null || !st.hasMoreTokens();){
            String k1 = in.readLine();
            if (k1 == null) return null;
            st = new StringTokenizer(k1);
        }
        return st.nextToken();
    }
    public static int ni () throws Exception {
        return Integer.parseInt(nx());
    }
    public static long nl() throws Exception{
        return Long.parseLong(nx());
    }
    public static double nd() throws Exception{
        return Double.parseDouble(nx());
    }
    public static void px(Object ... l1){
        System.out.println(Arrays.deepToString(l1));
    }
    public static boolean FLUSH = false;
    public static PrintWriter out = new PrintWriter(System.out, FLUSH);
    public static void p(Object ... l1){
        for (int i = 0; i < l1.length; i++){
            if (i != 0) out.print(' ');
            out.print(l1[i].toString());
        }
    }
    public static void pn(Object ... l1){
        for (int i = 0; i < l1.length; i++){
            if (i != 0) out.print(' ');
            out.print(l1[i].toString());
        }
        out.println();
    }
    
    public static void pn(Collection l1){
        boolean first = true;
        for (Object e: l1){
            if (first) first = false;
            else out.print(' ');
            out.print(e.toString());
        }
        out.println();
    }
    
    private static class IntL implements Iterable<Integer> {
        public int[] l1 = null;
        public int size = 0;

        public IntL(int initialCapacity) {
            this.l1 = new int[initialCapacity];
        }

        public IntL() {
            this(5);
        }

        public void add(int e) {
            if (size == l1.length) {
                l1 = Arrays.copyOf(l1, ((l1.length * 3) >> 1) + 1);
            }
            l1[size++] = e;
        }

        @Override
        public String toString() {
            StringBuilder fin = new StringBuilder();
            fin.append('{');
            for (int i = 0; i < size; i++) {
                if (i != 0) fin.append(", ");
                fin.append(l1[i]);
            }
            fin.append('}');
            return fin.toString();
        }

        @Override
        public Iterator<Integer> iterator() {
            return new It();
        }

        public class It implements Iterator<Integer> {
            int ptr = 0;

            @Override
            public boolean hasNext() {
                if (ptr < size) return true;
                return false;
            }

            @Override
            public Integer next() {
                int fin = l1[ptr];
                ptr++;
                return fin;
            }

            @Override
            public void remove() {}
        }
    }

    
}
