Capital

무향 그래프가 주어질 때, 각 도로의 방향이 S로부터의 거리가 작은 쪽에서 큰 쪽으로 향하도록 양의 실수 길이를 정할 수 있는 시작 도시 S를 모두 찾는다.

어려움8그래프BFS그리디구현아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

You are given NN cities connected by MM roads. Cities are numbered from 1 through NN, and roads are numbered from 1 through MM. For each pair of cities, there is a sequence of roads that connects those two cities. Road ii has the length L_iL\_i kilometre and connects city A_iA\_i and city B_iB\_i bidirectionally. Every road has a positive length, so L_i>0L\_i > 0. Unfortunately, you have forgotten the length of each road.

You observed that, for each road, all people on road ii are going from A_iA\_i to B_iB\_i, in a single direction. So, you assumed the hypothesis as follows:

  • There is a capital city called SS.
  • People are moving from the capital city to other cities. 
  • People try to move in the shortest path. So the length of the shortest path from SS to A_iA\_i is less than or equal to the length of the shortest path from SS to B_iB\_i.

Can you find the capital city SS which meets the criteria when you can assign the length of each road to be any positive real number? You may assume that there is at least one city that meets the criteria.

입력

The first line of the input contains two integers NN (2N5002 \le N \le 500) and MM (N1MN(N1)2N-1 \le M \le \frac{N(N-1)}{2}).

In the ii-th line of next MM lines, A_iA\_i and B_iB\_i are given. (1A_i, B_iN1 \le A\_i,\ B\_i \le N

There are no loops or multiple edges. Formally, A_iB_iA\_i \ne B\_i, and A_i, B_i=A_j, B_j    i=j\\{A\_i,\ B\_i\\} = \\{A\_j,\ B\_j\\} \implies i = j.

출력

In the first line, print the number of possible capital cities, KK.

In the second line, print KK space-separated integers which denotes all possible cities for the capital, in increasing order.