#abc212e. [abc212_e]Safety Journey
[abc212_e]Safety Journey
Problem Statement
The Republic of AtCoder has cities, called City , City , , City . Initially, there was a bidirectional road between every pair of different cities, but of these roads have become unusable due to deterioration over time. More specifically, for each , the road connecting City and City has become unusable.
Takahashi will go for a -day trip that starts and ends in City . Formally speaking, a -day trip that starts and ends in City is a sequence of cities such that holds and for each , and are different and there is still a usable road connecting City and City .
Print the number of different -day trips that start and end in City , modulo . Here, two -day trips and are said to be different when there exists an such that .
Constraints
- $0 \\leq M \\leq \\min\\left( \\frac{N(N-1)}{2},5000 \\right)$
- All pairs are pairwise distinct.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 1 4
2 3
Sample Output 1
4
There are four different trips as follows.
- ()
- ()
- ()
- ()
No other trip is valid, so we should print .
Sample Input 2
3 3 3
1 2
1 3
2 3
Sample Output 2
0
No road remains usable, so there is no valid trip.
Sample Input 3
5 3 100
1 2
4 5
2 3
Sample Output 3
428417047