Task 33

characteristic_polynomial (256000 kilobytes, 1000 milliseconds)

Submissions: 0 · Accepted: 0

Submit code

Statement

Characteristic polynomial

Work modulo \(p=1\,000\,000\,007\). Given an \(n\times n\) matrix \(A\),
compute

\[ \chi_A(x)=\det(xI-A). \]

Input

The first line contains \(n\). The next \(n\) lines contain \(A\).

Output

Print \(n+1\) coefficients

\[ c_n\ c_{n-1}\ \ldots\ c_1\ c_0, \]

where \(\chi_A(x)=c_nx^n+c_{n-1}x^{n-1}+\cdots+c_0\). Entries are modulo
\(p\), and any representatives are accepted.

Constraints

Sample test

Input
2
1000000005 999999998
9 1000000006

Output is validated by a special checker; any valid answer is accepted.