/+ dub.sdl:
    name "C"
    dependency "dcomp" version=">=0.6.0"
+/

import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;

int main() {
    Scanner sc = new Scanner(stdin);
    int h, w;
    sc.read(h, w);
    int[26] cnt;
    int[5] d;
    foreach (i; 0..h) {
        string s;
        sc.read(s);
        foreach (j; 0..w) {
            cnt[s[j]-'a']++;

            if (h-1-i > i) continue;
            if (w-1-j > j) continue;
            int x = 4;
            if (h-1-i == i) x /= 2;
            if (w-1-j == j) x /= 2;
            d[x]++;
        }
    }
//    writeln(cnt);
//    writeln(d);

    int[][] ans = new int[][](h, w);
    foreach (i; 0..h) {
        foreach (j; 0..w) {
            if (h-1-i <= i) continue;
            if (w-1-j <= j) continue;
            int f = -1;
            foreach (c; 0..26) {
                if (cnt[c] >= 4) {
                    f = c;
                    break;
                }
            }
            if (f == -1) {
                writeln("No");
                return 0;
            }
            cnt[f] -= 4;
            ans[i][j] = f + 'a';
            ans[h-1-i][j] = f + 'a';
            ans[i][w-1-j] = f + 'a';
            ans[h-1-i][w-1-j] = f + 'a';
        }
    }

    foreach (i; 0..h) {
        foreach (j; 0..w) {
            if (h-1-i < i || w-1-j < j) continue;
            if (h-1-i > i && w-1-j > j) continue;
            if (h-1-i == i && w-1-j == j) continue;
            int f = -1;
            foreach (c; 0..26) {
                if (cnt[c] >= 2) {
                    f = c;
                    break;
                }
            }
            if (f == -1) {
                return 0;
            }
            cnt[f] -= 2;
            ans[i][j] = f + 'a';
            ans[h-1-i][j] = f + 'a';
            ans[i][w-1-j] = f + 'a';
            ans[h-1-i][w-1-j] = f + 'a';
        }
    }

    foreach (i; 0..h) {
        foreach (j; 0..w) {
            if (h-1-i != i) continue;
            if (w-1-j != j) continue;
            int f = -1;
            foreach (c; 0..26) {
                if (cnt[c] >= 1) {
                    f = c;
                    break;
                }
            }
            cnt[f] -= 1;
            ans[i][j] = f + 'a';
            ans[h-1-i][j] = f + 'a';
            ans[i][w-1-j] = f + 'a';
            ans[h-1-i][w-1-j] = f + 'a';
        }
    }

    
    foreach (i; 0..h) {
        writeln(ans[i].map!(x => cast(char)(x)).array);
    }
    return 0;
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/scanner.d */
// module dcomp.scanner;

 
class Scanner {
    import std.stdio : File;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeChar, isStaticArray, isArray; 
    import std.algorithm : map;
    File f;
    this(File f) {
        this.f = f;
    }
    char[512] lineBuf;
    char[] line;
    private bool succ() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (true) {
            while (!line.empty && line.front.isWhite) {
                line.popFront;
            }
            if (!line.empty) break;
            if (f.eof) return false;
            line = lineBuf[];
            f.readln(line);
        }
        return true;
    }

    private bool readSingle(T)(ref T x) {
        import std.algorithm : findSplitBefore;
        import std.string : strip;
        import std.conv : parse;
        if (!succ()) return false;
        static if (isArray!T) {
            alias E = ElementType!T;
            static if (isSomeChar!E) {
                 
                 
                auto r = line.findSplitBefore(" ");
                x = r[0].strip.dup;
                line = r[1];
            } else {
                auto buf = line.split.map!(to!E).array;
                static if (isStaticArray!T) {
                     
                    assert(buf.length == T.length);
                }
                x = buf;
                line.length = 0;
            }
        } else {
            x = line.parse!T;
        }
        return true;
    }
    int read(T, Args...)(ref T x, auto ref Args args) {
        if (!readSingle(x)) return 0;
        static if (args.length == 0) {
            return 1;
        } else {
            return 1 + read(args);
        }
    }
}


 
 

 
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/foundation.d */
// module dcomp.foundation;
 
static if (__VERSION__ <= 2070) {
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            import std.algorithm : reduce;
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                import std.typecons : tuple;
                return reduce!fun(tuple(seed), r);
            }
        }
    }
     
}
version (X86) static if (__VERSION__ < 2071) {
    import core.bitop : bsf, bsr, popcnt;
    int bsf(ulong v) {
        foreach (i; 0..64) {
            if (v & (1UL << i)) return i;
        }
        return -1;
    }
    int bsr(ulong v) {
        foreach_reverse (i; 0..64) {
            if (v & (1UL << i)) return i;
        }
        return -1;   
    }
    int popcnt(ulong v) {
        int c = 0;
        foreach (i; 0..64) {
            if (v & (1UL << i)) c++;
        }
        return c;
    }
}
