Job Security

0

0 votes
Medium-Hard
Problem

Nick Fury has lost all control of the shield staff . The staff of shield exists in a heirarchial form , which was saved in the on a hard-drive . The data on the hard-drive was deleted by Zemo .So now , Fury needs to recover the heirarchy back. Some of the staff remembers remember who their superior was , and Fury makes a note of all this information given by the staff members. He then calls all the staff of shield and from the notes he made , arranges the staff in a way that no member is standing ahead of his superior . You have to tell him how many such arrangements are possible .

Input

Input starts with a line containing two space separeted integer N and M where N denotes the number of staff and M denotes their number of relations. Each of the following M lines will contain two integers X and Y , which denotes that X is superior to Y. .

Output

For each case, print the number of arrangements possible. The result can be large, print the result modulo 109+7.

Constraints

1 <= N <= 100000

1 <= X , Y <= N

X ≠ Y

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?