Cheat

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Eryk with his partner called "Synek" are planning next spoof. Usually they swindle foreingers by offering false banknotes on low exchange rate, so they have to drive a lot around country to avoid recognition.

But to do this, they need to find a city where they can build a base. Cities and roads in their homeland can be viewed as a directed graph with nn vertices numbered with integers from 11 to nn and specific property -- there is a directed edge from vertex ii to vertex i+1i + 1 for each valid ii.

Since they want to get back to base after each "trip" so they finds cycles really attractive. They decided to build a base in a city which lies on all cycles in their country. Because there can be multiple such cities, they asked you to write down all of them. If there is no cycle in the graph, they can build a base in any city.

Formally a cycle is a path starting and ending in the same city and visiting at least one other city (possibly multiple times).

입력

In the first line one integer Z50Z \le 50 is given, denoting number of testcases described in following lines. 

The first line of the test case contains two integers nn and mm, denoting the number of cities and roads. Each of the following mm lines two integers a_i,b_ia\_i, b\_i (a_ib_ia\_i \neq b\_i), denoting that there is a directed road from a_ia\_i to b_ib\_i. There can exist more than one road from a_ia\_i to b_ib\_i.

출력

For each test case your program should write the number of cities where Eryk and "Synek" can build base, followed by indices of those cities in ascending order.

제한

  • n\[1,500,000],m\[0,500,000]n \in \[1, 500\\,000], m \in \[0, 500\\,000]
  • sum of nn and sum of mm over all testcases does not exceed 1,000,0001\\,000\\,000.