#include "stdafx.h"
#include <string>
#include <iostream>

using namespace std;

int main()
{
	char matrica[500][10];
	int n, m;
	cin >> n; cin >> m;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> matrica[i][j];
		}
	}

	if (n == m)
	{
		for (int i = 0; i < n; i++)
		{
			matrica[i][i] = 'C';
		}
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				cout << matrica[i][j];
			}
			cout << "\n";
		}
	}
	else cout << -1;
	

    return 0;
}