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
is the minor of matrix A
formed by eliminating row i and column j from A
Given a matrix A, the elements of which are all integer numbers, your task is to calculate det(A) modulo 2005.
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.
For each matrix A,output exactly one line containing det(A) modulo 2005.