#include <iostream>
#include <vector>

using namespace std;

struct Resultat;

Resultat matriuX(const vector< vector<int> > &mat);

int main() {
	int f, c;
	cin >> f >> c;
	vector< vector<int> > mat(f, vector<int>(c, 0));
  
	for (int i = 0; i < f; ++i) {
		for (int j = 0; j < c; ++j) {
			cin >> mat[i][j];
		}
	}

	Resultat res = matriuX(mat);
	
	for (int i = 0; i < f; ++i) {
		cout << res.matriu[i][0];
		for (int j = 1; j < c; ++j) {
			cout << ' ' << res.matriu[i][j];
		}
		cout << endl;
	}
	cout << "Elements canviats: " << res.canviat << endl;

	return 0;
}
