# Problem A: Alien's Counting

Natsuki and her friends were taken to the space by an alien and made friends with a lot of aliens. During the space travel, she discovered that aliensf hands were often very different from humansf. Generally speaking, in a kind of aliens, there are *N* fingers and *M* bend rules on a hand. Each bend rule describes that a finger A always bends when a finger B bends. However, this rule does not always imply that the finger B bends when the finger A bends.

When she were counting numbers with the fingers, she was anxious how many numbers her alien friends can count with the fingers. However, because some friends had too complicated rule sets, she could not calculate those. Would you write a program for her?

## Input

*N M*

*S*_{1} *D*_{1}

*S*_{2} *D*_{2}

.

.

.

*S*_{M} *D*_{M}

The first line contains two integers *N* and *M* (1 ≤ *N* ≤ 1000, 0 ≤ *M* ≤ 1000) in this order. The following *M* lines mean bend rules. Each line contains two integers *S*_{i} and *D*_{i} in this order, which mean that the finger *D*_{i} always bends when the finger *S*_{i} bends. Any finger appears at most once in *S*.

## Output

Calculate how many numbers her alien friends can count with the fingers. Print the answer modulo 1000000007 in a line.

## Sample Input 1

5 4
2 3
3 4
4 3
5 4

## Output for the Sample Input 1

10

## Sample Input 2

5 5
1 2
2 3
3 4
4 5
5 1

## Output for the Sample Input 2

2

## Sample Input 3

5 0

## Output for the Sample Input 3

32