Knights of the Round Table

No attempts yetTime limit3sMemory limit256 MB

Problem

K knights sit at seats 1..K around a circle. The first D distracted knights already sat (knight assigned seat A is on seat B). Each remaining knight enters, tries his own seat, and if it is taken walks clockwise to the first free seat. Count distinct final seatings over all entry orders of the remaining knights, modulo 10^9+7.

Input

Several test cases. Each has K, D, then D lines with A and B meaning the knight assigned seat A sat on seat B.

Output

For each test case, print the number of distinct final distributions modulo 10^9+7.