404348: GYM101484 I Matrix Sum

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Matrix Sumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Sancho is a matrix lover. Today he decided to play with a square matrix M with N rows and N columns. Every cell i, j of this matrix contains either 0 or 1.

From this matrix M he created another matrix A. Every cell i, j in this new matrix A contains the sum of the values of the cells in M that are in row i or column j. The element in the cell i, j of the matrix M should be added only once. Formally:

Unfortunately, Sancho lost the original matrix M and now, having only matrix A, he wonders what is the number of matrices M, such that matrix A can be created from M.

Input

The first line of the input contains a single integer N (1 ≤ N ≤ 103), indicating the number of rows and columns of matrices M and A.

Each of the next N lines contains N integers. The j-th element of the i-th line Aij (0 ≤ Aij ≤ 104) is the value of the cell i, j of matrix A.

Output

Output a single integer: the number of matrices M that could have been used to create the matrix A when the process described above is followed.

ExamplesInput
2
1 1
1 0
Output
1
Input
2
1 1
0 0
Output
0

Source/Category

加入题单

算法标签: