Problem J
Stand in a Line
Input: Standard Input

Output: Standard Output

 

All the people in the byteland want to stand in a line in such a way that no person stands closer to the front of the line than his father. You are given the information about the people of the byteland.  You have to determine the number of ways the bytelandian people can stand in a line.

 

Input

First line of the input contains T (T<14) the number of test case. Then following lines contains T Test cases.

Each test case starts with 2 integers n (1≤n≤40000) and m (0≤m<n).  n is the number of people in the byteland and m is the number of people whose father is alive. These n people are numbered 1...n.Next m line contains two integers a and b denoting that b is the father of a. Each person can have at most one father. And no person will be an ancestor of himself.

 

 

Output

For each test case the output contains a single line denoting the number of different ways the soldier can stand in a single line. The result may be too big. So always output the remainder on dividing ther the result by 1000000007.

 

Sample Input                                  Output for Sample Input

3

3 2

2 1

3 1

3 0

3 1

2 1

 

2

6

3

 

 


Problem setter: Abdullah-al-Mahmud

Special Thanks: Derek Kisman