This problem asks: How many different routes are there from city to city in a flight network (DAG)?
The answer can be huge, so return it modulo . A route is a sequence of cities where you can fly from each city to the next. This is a path counting problem on a DAG.
Instead of taking min or max when relaxing edges, you add: dp[v] = dp[v] + dp[u] for each edge . Each path to extends to a path to .