eigenvalues

(256000 kilobytes, 1000 milliseconds)

Submissions: 0 · Accepted: 0

Submit code

Statement

Eigenvalues of a triangular matrix

Work in \(\mathbb F_p\), where \(p=1\,000\,000\,007\). You are given an upper
triangular matrix (A\). Its characteristic polynomial is

\[ \det(xI-A)=\prod_{i=0}^{n-1}(x-A_{i,i}), \]

so its eigenvalues, counted with algebraic multiplicity, are exactly its
diagonal entries.

Input

The first line contains (n). The next (n) lines contain an upper triangular
(n\times n) matrix (A).

Output

Print the (n) eigenvalues, counted with multiplicity, in nondecreasing order.
All values are compared modulo (p).

Constraints