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.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.util.ArrayDeque;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Zyflair Griffane
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		PandaScanner in = new PandaScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		E solver = new E();
		solver.solve(1, in, out);
		out.close();
	}
}

class E {
    public void solve(int testNumber, PandaScanner in, PrintWriter out) {
        int n = in.nextInt();
        ArrayDeque<Edge>[] adj = new ArrayDeque[n + 1];
        int[] degree = new int[n + 1];
        for (int i = 1; i < n + 1; i++) {
            adj[i] = new ArrayDeque<>();
        }
        for (int i = 1; i < n; i++) {
            int u = in.nextInt();
            int v = in.nextInt();
            boolean repair = in.nextInt() == 2;
            adj[u].add(new Edge(u, v, repair));
            adj[v].add(new Edge(v, u, repair));
        }
        for (int i = 1; i < n + 1; i++) {
            degree[i] = adj[i].size();
        }
        IntDeque q = new IntDeque();
        IntDeque toCheck = new IntDeque();
        int[] par = new int[n + 1];
        q.add(1);
        while (!q.isEmpty()) {
            boolean leaf = true;
            int u = q.poll();
            for (Edge e: adj[u]) {
                if (par[u] != e.v) {
                    par[e.v] = u;
                    q.add(e.v);
                    leaf = false;
                }
            }
            if (leaf) {
                toCheck.add(u);
            }
        }
        IntDeque res = new IntDeque();
        Loop: while (!toCheck.isEmpty()) {
            int u = toCheck.poll();
            for (Edge e: adj[u]) {
                if (par[u] == e.v) {
                    if (e.repair) {
                        res.add(u);
                        continue Loop;
                    }
                    else {
                        degree[e.v]--;
                        if (degree[e.v] < 2) {
                            toCheck.add(e.v);
                        }
                    }
                }
            }
        }
        out.println(res.size());
        out.println(res);
    }
    public class Edge {
        int u;
        int v;
        boolean repair;
        public Edge(int u, int v, boolean repair) {
            this.u = u;
            this.v = v;
            this.repair = repair;
        }
    }
}

class PandaScanner {
    public BufferedReader br;
    public StringTokenizer st;
    public InputStream in;

    public PandaScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(this.in = in));
    }

    public String nextLine() {
        try {
            return br.readLine();
        }
        catch (Exception e) {
            return null;
        }
    }

    public String next() {
        if (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(nextLine().trim());
            return next();
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    }

class IntDeque implements Iterable<Integer> {

    private int capacity;
    private int size = 0;
    private int front = 0;
    private int back = 0;
    private int[] deque;
    public IntDeque() {
        this(100);
    }
    public IntDeque(int capacity) {
        this.capacity = capacity;
        deque = new int[capacity];
    }
    public void add(int x) {
        addLast(x);
    }
    public void addLast(int x) {
        ensureCapacity();
        size++;
        deque[back++] = x;
        if (back == capacity) {
            back = 0;
        }
    }
    public void ensureCapacity() {
        if (size == capacity) {
            int[] newDeque = new int[capacity << 1];
            for (int i = 0, j = front; i < size; i++, j++) {
                if (j == capacity) {
                    j = 0;
                }
                newDeque[i] = deque[j];
            }
            deque = newDeque;
            capacity <<= 1;
            front = 0;
            back = size;
        }
    }
    public boolean isEmpty() {
        return size == 0;
    }
    public Iterator<Integer> iterator() {
        return new Iterator<Integer>() {
            int done = 0;
            int curr = front;
            public boolean hasNext() {
                return done < size;
            }
            public Integer next() {
                Integer res = deque[curr++];
                if (curr == capacity) {
                    curr = 0;
                }
                done++;
                return res;
            }
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
    public int poll() {
        return pollFirst();
    }
    public int pollFirst() {
        if (size == 0) {
            throw new RuntimeException("IntDeque is empty!");
        }
        size--;
        int res = deque[front++];
        if (front == capacity) {
            front = 0;
        }
        return res;
    }
    public int size() {
        return size;
    }
    public String toString() {
        if (size == 0) {
            return "";
        }
        StringBuilder res = new StringBuilder();
        for (int i: this) {
            res.append(i);
            res.append(" ");
        }
        res.setLength(res.length() - 1);
        return res.toString();
    }
}

