#include <iomanip>
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n, m, i, x;
	string a;
	cin >> n >> m;
	i = 0;
	x = 1;
	string *A = new string[n * m];
	while (i < n * m)
	{
		cin >> a;
		A[i] = a;
		i++;
	}
	i = 0;
	if (n == m)
	{
		while (i < n * m)
		{
			A[i] = "C" ;
			i = i + (n + 1);
		}
		i = 0;
		while (i < n * m)
		{
			cout << A[i];
			i++;
			if (x >= n)
			{
				cout << endl;
				x = 0;
			}
			else 
			{
				x++;
			}
		}
	}
	else
	{
		cout << "-1";
	}
}