#P7112. 【模板】行列式求值

【模板】行列式求值

Description

Given an nn-order determinant AA, find A|A|. Output the result modulo pp.

Input Format

The first line contains two positive integers nn and pp.

Then follow nn lines. The (i+1)(i+1)-th line contains nn positive integers, where the jj-th number represents Ai,jA_{i,j}.

Output Format

Output the smallest non-negative integer value of A|A| modulo pp.

2 998244353
1 4
1 5
1

Hint

For 100%100\% of the testdata, 1n6001 \le n \le 600, 1ai,j<109+71 \le a_{i,j} < 10^9 + 7, 1p109+71 \le p \le 10^9 + 7.

Translated by ChatGPT 5