Title Description
In Gensokyo, the Kamishirasawa sound is a well-known teacher with a profound knowledge. Spring snow changes cause many roads in the world to be blocked by heavy snow, so that some students can not successfully reach the village where the Hui sound. So the comet decided to change to a village that could gather the largest number of people as a new teaching location. The earth is made up of N villages (numbered 1). N) and M Road, the road is divided into two kinds of one-way, one for two-way passage, respectively, with 1 and second mark. If there is a pathway from village A to village B, then we think we can reach village B from village A, which is recorded as (A, b). When (A, b) and (b,a) are satisfied at the same time, we think that A, B is absolutely connected, recorded as <A,B>. An absolute connected area is a collection of villages in which any two villages, X, Y, meet <X,Y>. Now your task is to find the largest absolute connected area and output The villages of this absolutely connected area sequentially. If there are two largest, the output dictionary order is minimal, such as the existence of 1,3,4 and 2,5,6 the largest connected regions, the output is 1,3,4.
Input/output format
Input format:
Line 1th: two positive integers n,m
2nd.. M+1 lines: three positive integers per line a,b,t, T = 1 indicates a one-way road from village A to B, T = 2 means that there is a two way road between Village A and a. Ensure that each road appears only once.
Output format:
Line 1th: 1 integers representing the maximum number of villages included in the absolute connected area.
Line 2nd: A number of integers, sequentially outputting the largest absolute connected area that contains the village number.