UOJ Logo 黑暗爆炸OJ

DARKBZOJ

#2107. Spoj2832 Find The Determinant III

Statistics 下载数据

Description

Problem code: DETER3 Given a NxN matrix A, find the Determinant of A % P. 给出一个尺寸为N×N的整数方阵A(N≤200),要求求出|A|%P的值(即A的行列式的值除以P的余数)。方阵中的数与P均为32位有符号类型可容纳的整数

Input

The first line of every test case contains two integers , representing N (0 < N < 201) and P (0 < P < 1,000,000,001). The following N lines each contain N integers, the j-th number in i-th line represents A[i][j] (- 1,000,000,001 < A[i][j] < 1,000,000,001).

Output

For each test case, print a single line contains the answer.

Sample Input

3 4
-840419217 -895520213 -303215897
537496093 181887787 -957451145
-305184545 584351123 -257712188


Sample Output

2

Hint

Source