14379 - 2024_DS_Summer_Assignment4_pD   

Description

You are given a directed graph with n vertices and m edges.

How many possible paths start from vertex 1 and end at vertex n?

The given graph is guaranteed to be acyclic (i.e., it has no cycles).

Input

The first input line has two integers n and m: the number of vertices and edges. The vertices are numbered 1, 2, ..., n.

After this, there are m lines describing the edges. Each line has two integers a and b: there is a edge from vertex a to vertex b.

 

Constraints

  • 1 ≤ n ≤ 10⁵
  • 1 ≤ m ≤ 2 ⋅ 10⁵
  • 1 ≤ a, b ≤ n

 

Output

Print one integer: the number of paths from vertex 1 to vertex n.

Since the result may be large, print it modulo 10⁹ + 7.

Sample Input  Download

Sample Output  Download

Tags




Discuss