Under construction

Still being built. Things may change

Capital

Time limit1sMemory limit1024 MB

Summary
Count the cities S for which some positive road lengths make every road's A end no farther from S than its B end.
Level

Medium7 of 10

Topics
Graph, Shortest path, Brute force
Solved
No attempts yet

Problem

There are 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 them. Road ii has length LiL_i kilometres and connects cities AiA_i and BiB_i in both directions. Every road has a positive length, so Li>0L_i > 0. The lengths of the roads are unknown.

For each road, all people on road ii travel from AiA_i to BiB_i in a single direction. Based on this, the following hypothesis is made:

  • There is a capital city SS.
  • People move from the capital to other cities.
  • People take the shortest path. So the shortest distance from SS to AiA_i is less than or equal to the shortest distance from SS to BiB_i.

Find every capital city SS that satisfies these conditions when each road length can be any positive real number. You may assume that at least one city satisfies the conditions.

Input

The first line contains two integers NN (2≤N≤5002 \le N \le 500) and MM (N−1≤M≤N(N−1)2N-1 \le M \le \frac{N(N-1)}{2}).

Each of the next MM lines contains AiA_i and BiB_i (1≤Ai,Bi≤N1 \le A_i, B_i \le N). There are no self-loops or multiple edges. That is, Ai≠BiA_i \ne B_i, and {Ai,Bi}={Aj,Bj}\{A_i, B_i\} = \{A_j, B_j\} implies i=ji = j.

Output

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

On the second line, print the KK possible capital cities in increasing order, separated by spaces.

Examples1

  1. Example 1

    Input
    2 1
    1 2
    
    Expected output
    1
    1