Problem

The determinant of a matrix ,

 ??

??

is commonly denoted det(A).

A determinant is defined to be

 ??

??

A determinant can be expanded "by minors" to obtain

??

 ?? ??

A general determinant for a matrix A has a value

 ??

??

with no implied summation over j and where (also denoted ) is the cofactor of defined by

 ??

??

and is the minor of matrix A formed by eliminating row i and column j from A. This process is called determinant expansion by minors (or "Laplacian expansion by minors," sometimes further shortened to simply "Laplacian expansion").

Given a matrix A, the elements of which are all integer numbers, your task is to calculate det(A) modulo 2005.

??

Input

The input will contain one or more test cases. The first line of each test case contains one integer n (n <= 100), representing the size of the matrix. The next n lines with n integer numbers each gives the elements of the matrix.
Note that the elements of the matrix are in the range [-32768,32767].

Input will be terminated by a value of 0 for n.

Output

For each matrix A,output exactly one line containing det(A) modulo 2005.

Sample Input

2
1 0
0 1

0

Sample Output

1

Author: Mathematica