Topological sort


Plus
Pin


Problem description Progress
ID 38569. Building
Темы: Depth walk    Topological sort   

A group of recruit soldiers arrived at the army unit N666. After meeting the ensign, it became obvious that only a miracle could save a soldier from working in the kitchen to peel potatoes.

The ensign, unable to remember the names, numbered the recruits from 1 to N. After that, he ordered them to line up in height (starting with the tallest). Even completely untrained recruits can cope with this simple task, but the trouble is, the ensign assured himself that he knows about some soldiers, which of them is higher than whom, and this is far from always true.

After three days of training, the recruits managed to find out what the ensign knows (or rather, thinks he knows). Help them, using this knowledge, to line up so that Comrade Ensign is satisfied.

Input
First, the numbers N and M are input to the program (1 < N <= 100, 1 <= M <= 5000) – the number of soldiers in the company and the number of pairs of soldiers, about which the ensign knows which of them is higher. Next come these pairs of numbers A and B, one per line (1 <= A,B <= N), which means that, in the opinion of the ensign, soldier A is higher than B. It is not guaranteed that all pairs of numbers in input data are different.

Imprint
In the first line print "Yes" (if you can line up so that the ensign is satisfied) or "No" (if not). After answering "Yes" on the next line print N numbers separated by spaces - one of the possible constructions.

Examples
# Input Output
1 4 5
1 2
23
34
14
4 1
No