时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld
题目描述
You are given an integer

, and

pairs of integers
%5C%20(1%5Cle%20i%5Cle%20m))
with
distinct 
, i.e.

for all

. You need to find the number of permutation

of length

satisfying

for all

. Since the number might be too large, you only need to output the answer modulo

.
Recall that a permutation of length

is a sequence of length

and contains

exactly once. For instance,

and

are permutations while

and

are not.
输入描述:
The first line contains two integers
and
, indicating the length of the permutation and the number of constraints.
The
-th of the following
lines contains two integers
and
indicating the constraint that
. It is guaranteed that all
are distinct.
输出描述:
Output an integer indicating the number of permutations satisfying the conditions modulo
.
示例4
输入
复制
10 7
1 2
3 2
5 4
7 8
2 6
4 6
8 6