#codefestival2016finalf. [codefestival_2016_final_f]Road of the King
[codefestival_2016_final_f]Road of the King
Problem Statement
There are towns in Takahashi Kingdom. They are conveniently numbered through .
Takahashi the king is planning to go on a tour of inspection for days. He will determine a sequence of towns , and visit town on the -th day. That is, on the -th day, he will travel from his current location to town . If he is already at town , he will stay at that town. His location just before the beginning of the tour is town , the capital. The tour ends at town , without getting back to the capital.
The problem is that there is no paved road in this kingdom. He decided to resolve this issue by paving the road himself while traveling. When he travels from town to town , there will be a newly paved one-way road from town to town .
Since he cares for his people, he wants the following condition to be satisfied after his tour is over: "it is possible to travel from any town to any other town by traversing roads paved by him". How many sequences of towns satisfy this condition?
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the number of sequences of towns satisfying the condition, modulo .
Sample Input 1
3 3
Sample Output 1
2
As shown below, the condition is satisfied only when or . Sequences such as , , do not satisfy the condition.
Sample Input 2
150 300
Sample Output 2
734286322
Sample Input 3
300 150
Sample Output 3
0