#P1240. 诸侯安置

诸侯安置

Description

A long time ago, there was a powerful empire whose territory was square-shaped, as shown in the figure.

The country has several feudal lords. Since these lords had made great contributions, the king planned to grant each of them a fief (one cell in the square grid). However, these lords are very warlike: if two lords are in the same row or the same column, they will go to war. The following figure shows the territory when n=3n=3, where the shaded cells indicate the lords’ positions. In the first two figures, the lords can attack each other; in the third figure, they cannot.

Naturally, the king does not want to see his lords fighting each other and causing unrest. Therefore, he hopes to arrange their positions so that no two lords can attack each other.

Now, given the side length nn of the square and the number of lords kk to be placed, find the total number of valid arrangements. (You only need to output the remainder when the number of arrangements is divided by 504504.)

Constraints: n100n \le 100, k2n22n+1k \le 2n^2 - 2n + 1.

Input Format

A single line containing two integers nn and kk, separated by a space.

Output Format

A single integer, the remainder when the number of valid arrangements is divided by 504504.

2 2

4

Hint

Note: Mirror images and rotations are considered different solutions.

Translated by ChatGPT 5