题目详情
C.How Does the Rook Move?
You are given an 𝑛×𝑛 chessboard where you and the computer take turns alternatingly to place white rooks & black rooks on the board respectively. While placing rooks, you have to ensure that no two rooks attack each other. Two rooks attack each other if they share the same row or column regardless of color.
A valid move is placing a rook on a position (𝑟, 𝑐) such that it doesn't attack any other rook.
You start first, and when you make a valid move in your turn, placing a white rook at position (𝑟, 𝑐), the computer will mirror you and place a black rook at position (𝑐, 𝑟) in its turn. If 𝑟=𝑐, then the computer can't mirror your move, and skips its turn.
You have already played 𝑘 moves with the computer (the computer tries to mirror these moves too), and you must continue playing the game until there are no valid moves remaining. How many different final configurations are possible when you continue the game after the 𝑘 moves? It is guaranteed that the 𝑘 moves and the implied computer moves are valid. Since the answer may be large, print it modulo .
Two configurations are considered different if there exists a coordinate (𝑟, 𝑐) which has a rook in one configuration, but not in the other or the color of the rook on the coordinate is different.
Input
The first line contains a single integer 𝑡 () — the number of test cases.
The first line of each test case contains two integers 𝑛𝑛 and 𝑘 () — the size of the chessboard and the number of moves you have