Preparing NOJ

Permutation

1000ms 0K

Description:

bobo has a permutation p1,p2,…,pn of 1,2,…,n.

Knowing m extra constraints of form pai<pbi, bobo wanna count the number of different permutations modulo (109+7).

It is guaranteed that there is at least one such permutation.

Input:

The input consists of several tests. For each tests:

The first line contains n,m (1≤n≤40,0≤m≤20). Each of the following m lines contain 2 integers ai,bi(1≤ai,bi≤n).

Output:

For each tests:

A single number denotes the number of permutations.

Sample Input:

3 1
1 2
3 2
1 2
2 3

Sample Output:

3
1

Info

HDU

Provider HDU

Origin 2014 Multi-University Training Contest 5

Code HDU4917

Tags

Submitted 6

Passed 5

AC Rate 83.33%

Date 06/03/2019 16:46:49

Related

Nothing Yet