LearnPy Hub
← Arena
AdvancedRating 1600

Paths in a DAG

Count the paths from node 1 to node n in a directed acyclic graph, mod 1 000 000 007.

Input

n m, then m lines 'u v' (u → v).

Output

A count.

Sample 1

Input
4 5
1 2
1 3
2 4
3 4
2 3
Output
3

Sample 2

Input
2 0
Output
0
solution.py
Output appears here
Paths in a DAG · Python Arena problem · LearnPy Hub