Reduced row echelon form
All arithmetic is performed in
\[
\mathbb{F}_p, \qquad p = 1\,000\,000\,007.
\]
You are given an \(n\times m\) matrix \(A\). Output its **reduced row echelon
form** (RREF), obtained using elementary row operations over \(\mathbb{F}_p\).
The RREF is unique. In particular, every nonzero row begins with a \(1\), that
leading \(1\) is the only nonzero entry in its column, and leading positions
move strictly to the right as the rows move down.
Input
The first line contains \(n\) and \(m\). The next \(n\) lines contain \(A\),
with \(m\) entries per line.
Output
Print the RREF of \(A\) as \(n\) rows with \(m\) integers per row. Every entry
is interpreted modulo \(p\); any integer representative is accepted.
Constraints
- \(1\le n,m\le 200\)
- Every matrix entry is an integer in \([0,p)\)