#include <iostream>
#include <stdlib.h>
#include <ctime>
using namespace std;
int main()
{
int K;
int L;
cin>>K;
cin>>L;
int M=K*L;
int D[K][L];
int E[M];
int count = 0;
for (int i = 0; i < K; ++i)
{
for (int j = 0; j < L; ++j)
{
cin>>D[i][j];
if (D[i][j] != 0)
{
E[count++] = D[i][j];
cout << D[i][j] << " ";
}
}
}
cout << " количество ненулевых элементов матрицы E = " << count << endl;
for (int u = 0; u < K; ++u)
{
for (int y = 0; y < L; ++y)
{
cout<<D[u][y]<<" ";
}
cout<<"\n";
}
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RkbGliLmg+CiNpbmNsdWRlIDxjdGltZT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBtYWluKCkgCnsKCWludCBLOwoJaW50IEw7CgljaW4+Pks7CgljaW4+Pkw7CglpbnQgTT1LKkw7CglpbnQgRFtLXVtMXTsKCWludCBFW01dOwoJaW50IGNvdW50ID0gMDsKCWZvciAoaW50IGkgPSAwOyBpIDwgSzsgKytpKQoJewoJCWZvciAoaW50IGogPSAwOyBqIDwgTDsgKytqKQoJCXsKCQkJY2luPj5EW2ldW2pdOwoJCQlpZiAoRFtpXVtqXSAhPSAwKQoJCQl7CgkJCQlFW2NvdW50KytdID0gRFtpXVtqXTsKCQkJCWNvdXQgPDwgRFtpXVtqXSA8PCAiICI7IAoJCQl9CgkJCQoKCQl9CgoJfQoKCWNvdXQgPDwgIiDQutC+0LvQuNGH0LXRgdGC0LLQviDQvdC10L3Rg9C70LXQstGL0YUg0Y3Qu9C10LzQtdC90YLQvtCyINC80LDRgtGA0LjRhtGLIEUgPSAiIDw8IGNvdW50IDw8IGVuZGw7Cglmb3IgKGludCB1ID0gMDsgdSA8IEs7ICsrdSkKCXsKCQlmb3IgKGludCB5ID0gMDsgeSA8IEw7ICsreSkKCQl7CgkJCWNvdXQ8PERbdV1beV08PCIgIjsKCQl9CgkJY291dDw8IlxuIjsKCX0KCXJldHVybiAwIDsKfQ==