You need to determine the number of ways to position rooks on an N \times N chessboard such that no two rooks share the same row or column. Additionally, certain cells on the board are restricted and cannot have rooks placed on them.
The first line contains the integer (1 \le N \le 3000). The next lines each contain characters, representing the board's cells. A character '1' indicates that a rook can be placed in that cell, while '0' indicates that it cannot.
Since the result can be very large, output a single number — the remainder of the total number of valid arrangements divided by .
Example 1