#include #include #include #include using namespace std; using namespace atcoder; using ll = long long; int main() { ll p, n, m; cin >> p >> n >> m; modint::set_mod(p); vector a(n, vector(m)); vector ba(n, vector(m)); for (ll i = 0; i < n; i++) { for (ll j = 0; j < m; j++) { ll ta; cin >> ta; a[i][j] = ba[i][j] = ta; } } vector> c(n); vector> f; for (ll j = 0; j < m; j++) { ll ib = -1; for (ll i = 0; i < n; i++) { if (a[i][j] != 0) { ib = i; break; } } if (ib < 0) continue; f.push_back(a[ib]); for (ll i = 0; i < n; i++) { if (i == ib) continue; modint mul = a[i][j] / a[ib][j]; c[i].push_back(mul); for (ll jj = j; jj < m; jj++) { a[i][jj] -= mul * a[ib][jj]; } } c[ib].push_back(1); a[ib].assign(m, 0); } ll r = f.size(); if (r == 0) { for (ll i = 0; i < n; i++) { c[i].push_back(0); } f.resize(1); f[0].assign(m, 0); r = 1; } if (n * m > (n + m) * r) { cout << 2 << endl; cout << n << " " << r << endl; for (ll i = 0; i < n; i++) { for (ll j = 0; j < r; j++) { cout << c[i][j].val() << " "; } cout << endl; } cout << r << " " << m << endl; for (ll i = 0; i < r; i++) { for (ll j = 0; j < m; j++) { cout << f[i][j].val() << " "; } cout << endl; } } else { cout << 1 << endl; cout << n << " " << m << endl; for (ll i = 0; i < n; i++) { for (ll j = 0; j < m; j++) { cout << ba[i][j].val() << " "; } cout << endl; } } return 0; }