#532 Placing Bishops on a Chessboard

Companies:
T-Bank
Themes:
AlgorithmsDynamic ProgrammingPractice

For New Year, a girl named Anya wished for a chessboard of size n × n. Thanks to a New Year miracle, her wish came true, and she also received k chess bishops.

Anya has studied mathematics for several years, so she became interested in the following question: in how many ways can exactly k bishops be placed on this board so that no two bishops attack each other according to chess rules?

She is not good at programming, so she asks you to calculate this value. Because the answer may be very large, print it modulo 10⁹ + 7.

Input

The only line contains two numbers n and k:

1 ≤ n ≤ 500
1 ≤ k ≤ n²

where n is the board size and k is the number of bishops.

Output

Print exactly one number — the number of ways to place k bishops on the board so that no two bishops attack each other. Print the answer modulo 10⁹ + 7.

Example 1

Input:
5 3

Output:
1124

Example 2

Input:
2 2

Output:
4

Example 3

Input:
4 3

Output:
232

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in