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 CPP):

Solution:
#include <bits/stdc++.h>
namespace std {
template <typename A, typename B>
inline string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
inline string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
inline string to_string(tuple<A, B, C, D> p);
inline string to_string(const string& s) { return '"' + s + '"'; }
inline string to_string(const char* s) { return to_string((string)s); }
inline string to_string(bool b) { return (b ? "true" : "false"); }
inline string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
inline string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
inline string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
inline string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
inline string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
inline string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
}  // namespace std
inline void debug_out() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
inline void debug_out(Head H, Tail... T) {
  std::cerr << " " << std::to_string(H);
  debug_out(T...);
}
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  for (int tt = 0; tt < T; tt++) {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<vector<int>> e(n);
    for (int i = 0; i < m; i++) {
      int v, u;
      scanf("%d%d", &v, &u);
      v--;
      u--;
      e[v].push_back(u);
    }
    vector<int> mask(n, 0);
    vector<int> kill;
    for (int i = 0; i < n; i++) {
      if (mask[i] == 2) {
        continue;
      }
      if (mask[i] == 0) {
        for (auto v : e[i]) {
          if (mask[v] == 0) {
            mask[v] = 1;
          }
        }
      }
      if (mask[i] == 1) {
        for (auto v : e[i]) {
          mask[v] = 2;
        }
      }
    }
    for (int v = 0; v < n; v++) {
      if (mask[v] == 2) {
        kill.push_back(v);
      }
    }
    assert((int)kill.size() * 7 <= n * 4);
    cout << kill.size() << "\n";
    for (auto x : kill) {
      cout << x + 1 << " ";
    }
    puts("");
  }
  return 0;
}