Task 39

eigenspace (256000 kilobytes, 1000 milliseconds)

Submissions: 0 · Accepted: 0

Submit code

Statement

Eigenspace of a matrix

Work in \(\mathbb F_p\), where \(p=1\,000\,000\,007\). Given a square matrix
\(A\) and a scalar \(\lambda\), find a basis of the eigenspace

\[ E_\lambda=\{v:(A-\lambda I)v=0\}. \]

Input

The first line contains (n) and \(\lambda\). The next (n) lines contain
the (n\times n) matrix (A).

Output

Print the dimension (k), followed by (k) vectors of length (n). They must
be linearly independent and span (E_\lambda). If \(\lambda\) is not an
eigenvalue, print (0) and no vectors.

Constraints

Sample test

Input
3 3
8 4 3
3 1000000002 1000000006
999999997 999999998 1000000002

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