Problem: Arthur owns a ski resort on a mountain. There are n landing spots on the mountain numbered from 1 to n from the top to the foot of the mountain. The spots are connected with one-directional ski tracks. All tracks go towards the foot of the mountain, so there are no directed cycles formed by the tracks. There are at most two tracks leaving each spot, but many tracks may enter the same spot.

A skier can start skiing from one spot and stop in another spot if there is a sequence of tracks that lead from the starting spot and end in the ending spot. Unfortunately, recently there were many accidents, because the structure of the resort allows a skier to go through dangerous paths, by reaching high speed and endangering himself and the other customers. Here, a path is called dangerous, if it consists of at least two tracks.

Arthur wants to secure his customers by closing some of the spots in a way that there are no dangerous paths in the resort. When a spot is closed, all tracks entering and leaving that spot become unusable. 

Formally, after closing some of the spots, there should not be a path that consists of two or more tracks.

Arthur doesn't want to close too many spots. He will be happy to find any way to close at most 4/7n spots so that the remaining part is safe. Help him find any suitable way to do so.

Input

The first line contains a single positive integer T — the number of test cases. T test case description follows.

The first line of each description contains two integers n and m (1 ≤ n ≤ 2 ⋅ 10^5) — the number of landing spots and tracks respectively.

The following m lines describe the tracks. Each of these lines contains two integers x and y (1 ≤ x < y ≤ n) — indices of the starting and finishing spots for the respective track. It is guaranteed that at most two tracks start at each spot. There may be tracks in which starting and finishing spots both coincide.

It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.

Output

For each test case, print a single integer k (0 ≤ k ≤ 4/7n) — the number of spots to be closed. In the next line, print k distinct integers — indices of all spots to be closed, in any order.

If there are several answers, you may output any of them. Note that you don't have to minimize k. It can be shown that a suitable answer always exists.

Example

Input


2
4 6
1 2
1 3
2 3
2 4
3 4
3 4
7 6
1 2
1 3
2 4
2 5
3 6
3 7


Output


2
3 4 
4
4 5 6 7 

Note

In the first sample case, closing any two spots is suitable.

In the second sample case, closing only the spot 1 is also suitable.

Solution (in JAVA):

Solution:
/**
 * @author derrick20
 */

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

public class SkiAccidents3do implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new SkiAccidents3do(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
/*
1
5 7
1 3
1 4
3 4
3 2
2 4
2 5
4 5

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

1
5 7
1 2
2 3
2 4
1 4
3 4
3 5
4 5
 */
        int T = sc.nextInt();
        while (T-- > 0) {
            int N = sc.nextInt();
            int M = sc.nextInt();
            adjList = new TreeSet[N];
            Arrays.setAll(adjList, i -> new TreeSet<>());
            int[] inDeg = new int[N];
            for (int i = 0; i < M; i++) {
                int u = sc.nextInt() - 1;
                int v = sc.nextInt() - 1;
                adjList[u].add(v);
                inDeg[v]++;
            }
            StringBuilder deleted = new StringBuilder();
            int[] type = new int[N];
            int ct = 0;
            for (int root = 0; root < N; root++) {
                // fill up each DAG. We greedily stay ahead throughout
                // the process by only deleting things 2 away from us
                // when needed. At worst this gives 4/7 for each "root"
                // we delete from

                /* Key issue: we need to remove nodes in topological order:
                The input is designed so all edges are x -> y, x < y. That
                means every straight path is increasing. By going through
                each node's outgoing edges, then all the incoming edges
                entering a given node will have to be completed before it's
                done. So, if any of these go back up at least 2, then it'll
                be deletable.
                 */
                if (type[root] == 0) {
                    for (int adj : adjList[root]) {
                        if (type[adj] != 2) {
                            type[adj] = 1;
                        }
                    }
                } else if (type[root] == 1) {
                    for (int adj : adjList[root]) {
                        if (type[adj] != 2) {
                            type[adj] = 2;
                            ct++;
                            deleted.append(adj + 1).append(" ");
                        }
                    }
                } else {
//                    deleted.append(root + 1).append(" ");
                }
            }
//            ASSERT(7 * ct <= 4 * N);
            if (7 * ct > 4 * N) {
                System.out.println(Arrays.toString(adjList));
            }
            out.println(ct);
            out.println(deleted);
        }
        out.close();
    }

/*
1
10 10
1 4
1 5
4 9
5 10
6 4
6 5
2 6
2 7
7 8
8 10

1
7 7
1 4
1 6
2 5
5 6
6 7
3 4
4 5
 */

    static TreeSet<Integer>[] adjList, radjList;
    static boolean[] vis;

    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }

    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }

    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}