P25373 [AtCoder] Road of the King
提高+
题目描述

Problem Description

In the Kingdom of Takahashi, there are $ N $ towns, each assigned a number from $ 1 $ to $ N $.

The king of this kingdom, Takahashi-kun, is planning a tour of $ N $ towns over $ M $ days. In his plan, he decides on a sequence of towns $ c $ and on the $i\ (1 \leq i \leq M)$ day, he will visit town $ c_i $. That is, on the $ i $th day, he will move from his current town to town $ c_i $. However, if his current town is already town $ c_i $, he will not move. Takahashi-kun initially starts in town $ 1 $.

Unfortunately, there are no roads in this kingdom. Takahashi-kun decides to build roads as he walks. When Takahashi-kun moves from town $ a $ to town $ b $, a one-way road from town $ a $ to town $ b $ is created.

Being a king who cares for his people, Takahashi-kun wants to ensure that by the time he reaches his final destination on the last day of his tour, the condition "from any town to any other town, it is possible to move by following the roads built by Takahashi-kun" is satisfied. How many such sequences of towns $ c $ can be considered?

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $

Output Format

Output the answer modulo $1000000007\ (=10^9+7)$.

Sample Input and Output

Sample Input #1

3 3

Sample Output #1

2

Sample Input #2

150 300

Sample Output #2

734286322

Sample Input #3

300 150

Sample Output #3

0

Notes/Hints

Constraints

  • $2 \leq N \leq 300$
  • $1 \leq M \leq 300$

Sample Explanation 1

As shown in the figure below, only $ c = (2, 3, 1) $ or $ c = (3, 2, 1) $ satisfy the condition, while $ c = (2, 3, 2) $, $ c = (2, 1, 3) $, or $ c = (1, 2, 2) $ do not satisfy the condition. ![](https://atcoder.jp/img/code-festival-2016-final/199a3fd8d2aed75750901a206c8b7e76.png)

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3
样例输出
2