A scheduler runs n tasks in synchronized rounds. A directed edge u v means u must finish before v can start. Each task takes exactly one round, and there are unlimited workers, so a task runs in the earliest round in which all its prerequisites are already finished. Round 1 runs all tasks with no prerequisites, round 2 runs all tasks whose prerequisites all finished by round 1, and so on. Output the number of tasks completed in each round, in round order.
Input format
Line 1: two integers n and m — the number of nodes (labeled 0 through n-1) and the number of directed edges.
Each of the next m lines: two integers , a directed edge from to (read as: must come before ).
It is guaranteed the graph is acyclic, with no self-loops and no duplicate edges.
Output format
One line with the batch sizes: for round 1, round 2, ..., up to the last non-empty round, space-separated.
Constraints
- 1 <= n <= 2000
- 0 <= m <= 5000
- 0 <= u, v <= n-1; the graph is a DAG