e-olymp
Competitions

Topological sort

Ordering tasks

John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task is only possible if other tasks have already been executed.

Input

Consist of several instances of the problem. Each instance begins with a line containing two integers: number of tasks n (numbered from 1 to n, 1n100) and number m of direct precedence relations between tasks. After this, there will be m lines with two integers i and j, representing the fact that task i must be executed before task j.

An instance with n = m = 0 will finish the input.

Output

For each instance, print a line with n integers representing the tasks in a possible order of execution.

prb10235.gif

Time limit 1 second
Memory limit 128 MiB
Input example #1
6 6
1 2
3 2
4 2
2 5
6 5
4 6
3 1
3 2
0 0
Output example #1
3 1 4 2 6 5
1 3 2