Now you have a stack and $n$ numbers $1,2,3,…,n$. These $n$ numbers are pushed in the order and popped if the number is at the top of the stack. You can read the sample to get more details.
This question is quite easy. Therefore I must give you some limits.
There are $m$ limits, each is expressed as a pair$<A,B>$ means the number $A$ must be popped before $B$.
Could you tell me the number of ways that are legal in these limits?
I know the answer may be so large, so you can just tell me the answer mod $1000000007({10}^{9}+7)$.