#P7776. Characteristic Polynomial

    ID: 20962 Type: Default 1000ms 256MiB

Characteristic Polynomial

Characteristic Polynomial

Given an integer n and an n × n matrix A, compute the characteristic polynomial of A under modulo \(998244353\). The characteristic polynomial is defined as:

\[ \chi_A(x)=\det(xI-A)=x^n+c_{n-1}x^{n-1}+\cdots+c_0 \]

Output the coefficients of \(\chi_A(x)\) in order of descending powers of \(x\). Note that \(c_{n-1}, \ldots, c_0\) should be computed modulo 998244353.

inputFormat

The first line contains an integer n ( 1 ≤ n ≤ 300).

The following n lines each contain n space-separated integers representing the matrix A. All entries are given modulo 998244353.

outputFormat

Output a single line containing n+1 space-separated integers. These represent the coefficients of the characteristic polynomial \(\chi_A(x)=x^n+c_{n-1}x^{n-1}+\cdots+c_0\) in descending order starting with the coefficient of \(x^n\), which is always 1.

sample

1
5
1 998244348