#agc046f. [agc046_f]Forbidden Tournament
[agc046_f]Forbidden Tournament
Problem Statement
Given are integers and , and a prime number . Find the number, modulo , of directed graphs with vertices that satisfy below. Here, the vertices are distinguishable from each other.
- is a tournament, that is, contains no duplicated edges or self-loops, and exactly one of the edges and exists for any two vertices and .
- The in-degree of every vertex in is at most .
- For any four distinct vertices , , , and in , it is not the case that all of the six edges , , , , , and exist simultaneously.
Constraints
- and are integers.
- is a prime number.
Input
Input is given from Standard Input in the following format:
Output
Print the number of directed graphs that satisfy the conditions, modulo .
Sample Input 1
4 3 998244353
Sample Output 1
56
Among the graphs with four vertices, are isomorphic to the forbidden induced subgraphs, and the other satisfy the conditions.
Sample Input 2
7 3 998244353
Sample Output 2
720
Sample Input 3
50 37 998244353
Sample Output 3
495799508