Task 24

rank_basis (256000 kilobytes, 1000 milliseconds)

Submissions: 0 · Accepted: 0

Submit code

Statement

Basis of a row space

All arithmetic is performed in the finite field

\[ \mathbb{F}_p, \qquad p = 1\,000\,000\,007. \]

You are given an \(n \times m\) matrix \(A\). The **row space** of \(A\) is the
set of all linear combinations of its rows over \(\mathbb{F}_p\).

Output any basis of this row space. The basis does not have to be unique, and
its vectors may be printed in any order.

Input

The first line contains two integers \(n\) and \(m\). The next \(n\) lines
contain the matrix \(A\), with \(m\) entries per line.

Output

Print an integer \(r\), the dimension of the row space. Then print \(r\) rows,
each containing \(m\) integers. These rows must be linearly independent and
must span exactly the same space as the rows of \(A\).

Every matrix entry is interpreted modulo \(p\); any integer representative is
accepted.

Sample test

Input
2 5
0 0
0 0
0 0

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