Placement of Rooks#3699

Placement of Rooks

1 second
256 megabytes
Medium

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.

Input

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.

Output

Since the result can be very large, output a single number — the remainder of the total number of valid arrangements divided by .

Examples

Example 1

Loading
Loading