A library has n modules forming a directed acyclic graph. A directed edge u v means module u is required before module v (so v is downstream of u). For each module, count how many distinct modules are reachable from it by following directed edges — that is, its number of descendants (not counting itself). Output one count per module.
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 n space-separated integers: the descendant count of node 0, node 1, ..., node n-1.
Constraints
- 1 <= n <= 40
- 0 <= m <= 400
- 0 <= u, v <= n-1; the graph is a DAG