QOJ.ac

QOJ

実行時間制限: 3 s メモリ制限: 256 MB 満点: 100

#843. Road Planning

統計

The people of country R live in a city with $k$ streets, each containing $n$ houses arranged in an orderly grid. Initially, every pair of adjacent houses is connected by a road. In short, these houses are connected by a grid-like road network. However, the municipal government is currently facing a budget shortage and cannot maintain so many roads. They must reduce the number of roads as much as possible while ensuring that any two houses remain connected. Note that roads on the streets can also be partially removed. It is easy to see that exactly $kn - 1$ roads will remain. Please calculate the total number of ways to satisfy this requirement.

The answer should be taken modulo $P = 10^9 + 7$.

Input

A single line containing two integers $k$ and $n$.

Output

Output a single integer representing the answer.

Subtasks

Test Case ID $k \le $ $n \le $
$1$ $2$ $5$
$2$ $3$
$3$ $2$ $10^5$
$4$ $10^9$
$5$ $3$ $10^4$
$6$ $4$
$7$ $5$
$8$ $10^9$
$9$ $6$ $10^3$
$10$ $10^9$

For $100\%$ of the data, it is guaranteed that $2 \le k \le 6$ and $1 \le n \le 10^9$.

Examples

Input 1

2 2

Output 1

4

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.