#P10221. [省选联考 2024] 重塑时光

[省选联考 2024] 重塑时光

Problem Description

T is studying the events that happened during a certain period of time. After observation, there are nn events numbered from 11 to nn that occur in this period one by one in some order, where the ii-th event to occur is pip_i. This permutation pp that describes the order in which events occur is called the timeline of this period.

Suddenly, the evil creature S attacked this timeline and changed the order pp into a permutation chosen uniformly at random from all permutations of length nn. Moreover, S cut the timeline with scissors: by performing kk operations, S split the permutation pp into (k+1)(k + 1) segments.

More specifically, when S performs the ii-th operation, the permutation pp together with all previously inserted cut points forms a sequence of length (n+i1)(n + i - 1). This sequence has (n+i)(n + i) insertion positions in total: between every pair of adjacent elements, and also at the beginning and the end of the sequence. S will choose one of these insertion positions uniformly at random and insert a new cut point. Finally, S cuts the sequence at the kk inserted cut points, splitting the permutation pp into (k+1)(k + 1) sequences. Some of these (k+1)(k + 1) sequences may be empty.

To save this timeline that is about to be destroyed, T decides to concatenate these (k+1)(k + 1) sequences in some order to form a new permutation of length nn, thus creating a new timeline. However, due to certain logical relationships among events, there are precedence requirements on their occurrence times. After research, there are mm precedence requirements (u,v)(u, v), requiring that event uu must occur before event vv. That is, the position of uu in the timeline must be before vv.

Please write a program to compute the probability that there exists at least one way to reorder these (k+1)(k + 1) segments and concatenate them into a new timeline such that all mm precedence requirements are satisfied.

To avoid precision errors, output the answer modulo 109+710^9 + 7. Formally, it can be proven that the answer can be expressed as an irreducible fraction pq\frac{p}{q}. You need to output an integer xx such that 0x<109+70 \le x < 10^9+7 and qxp(mod109+7)qx \equiv p \pmod {10^9+7}. It can be proven that such an xx always exists under the constraints of this problem.

Input Format

The first line contains three integers n,m,kn, m, k, describing the number of events, the number of precedence requirements among events, and the number of cut operations performed by S.

The next mm lines each contain two integers u,vu, v, representing one precedence requirement.

Output Format

Output one line with one integer, representing the required answer.

2 1 1
1 2
666666672
3 0 2

1
4 4 4
1 2
1 3
1 4
2 4
937500007

Hint

[Sample 1 Explanation]

If event 11 occurs earlier than event 22, then no matter how you concatenate the segments, it is always feasible and the requirement can always be satisfied. Otherwise, the requirement can be satisfied only if the cut position lies between the occurrence times of event 11 and event 22. The answer is $\frac{1}{2}+\frac{1}{2}\times \frac{1}{3}=\frac{2}{3}$.

[Sample 2 Explanation]

There are no precedence requirements between events, so any concatenation is feasible. The answer is 11.

[Sample 4]

See timeline4.in/ans in the attachment.

[Sample 5]

See timeline5.in/ans in the attachment.

This sample satisfies Special Property B in the Constraints.

[Sample 6]

See timeline6.in/ans in the attachment.

This sample satisfies Special Property A in the Constraints.

[Sample 7]

See timeline7.in/ans in the attachment.

[Subtasks]

For all testdata,

  • 1n151 \le n \le 15,
  • 0mn(n1)20 \le m \le \frac{n(n-1)}{2}, 0kn0 \le k \le n,
  • 1u<vn1 \le u < v \le n, and it is guaranteed that there are no two identical pairs (u,v)(u,v).
Test Point nn mm kk Special Property
11 3\le 3 =n1=n-1 =0=0 B
22 5\le 5 n(n1)2\le \frac{n(n-1)}{2} n\le n None
3,43,4 14\le 14 =n1=n-1 B
55 =0=0 A
66 n\le n
77 =0=0 None
88 =n(n1)2=\frac{n(n-1)}{2}
9,109,10 9\le 9 15\le 15
1111 13\le 13 n(n1)2\le \frac{n(n-1)}{2} =0=0
1212 n\le n
131713 \sim 17 14\le 14
182018\sim 20 15\le 15

Special Property A: For each event xx, there exists at most one precedence requirement (u,v)(u, v) such that v=xv = x.

Special Property B: For all precedence requirements (u,v)(u, v), it holds that u=1u = 1.

Translated by ChatGPT 5