// Example program
#include <iostream>
#include <string>


using namespace std;

int main()
{
    int64_t n,m;

    cin >> n >> m;

    int64_t k= n*m;
    int64_t p =0;



    for (int64_t i=0; i<k; i++)
    {
        char d;
         cin >> d;
         if (d=='.') p++;
    }

    if (p<k) cout << "-1"; else

    {
     if (n!=m) cout << "-1"; else
     {
         for (int64_t i=0; i<n; i++)
           {
            for (int64_t j=0; j<n; j++)
           {
               if (i==j) cout << "C"; else cout << "."; }

             cout << endl;
           }
     }
    }


}