#include "bits/stdc++.h" #include "atcoder/all" using namespace std; using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int H, W; cin >> H >> W; vectorS(H); rep(i, H) { cin >> S[i]; } reverse(all(S)); int brank = 0; vectorlist; rep(i, H) { int block = 0; rep(j, W) { if ('#' == S[i][j]) {block++;} } if (W == block) { //不正入力を殺す cout << "No" << endl; return 0; } if (0 == block) { brank++; continue; } if (brank) { //不正入力を殺す cout << "No" << endl; return 0; } list.push_back(i); } int limit3 = 1; rep(i, H) { limit3 *= 3; } vectorC(52); rep(i, 26) { C[i] = 'a' + i; C[i + 26] = 'A' + i; } vectorX(H); vectornewS(H); rep(i, limit3) { int copyi = i; int count0 = 0; rep(j, H) { X[j] = copyi % 3; copyi /= 3; if (0 == X[j]) { count0++; } } if (count0 != list.size()) { continue; } int now = 0; rep(j, H) { if (0 == X[j]) { newS[j] = S[list[now]]; now++; } else if (1 == X[j]) { newS[j].clear(); rep(k, W) { newS[j] += '.'; } } else { newS[j].clear(); rep(k, W) { newS[j] += '#'; } } } mf_graphg(H * W + 2); int s = H * W; int t = H * W + 1; int count = 0; rep(j, H) { rep(k, W) { if ('#' != newS[j][k]) { continue; } count++; int v = j * W + k; if (0 == (j + k) % 2) {g.add_edge(s, v, 1);} else {g.add_edge(v, t, 1);} } } rep(j, H) { rep(k, W) { if ('#' != newS[j][k]) { continue; } if (1 == (j + k) % 2) { continue; } int v = j * W + k; if ((j) && ('#' == newS[j - 1][k])) { int w = (j - 1)*W + k; g.add_edge(v, w, 1); } if ((k) && ('#' == newS[j][k - 1])) { int w = j * W + (k - 1); g.add_edge(v, w, 1); } if ((j + 1 < H) && ('#' == newS[j + 1][k])) { int w = (j + 1)*W + k; g.add_edge(v, w, 1); } if ((k + 1 < W) && ('#' == newS[j][k + 1])) { int w = j * W + (k + 1); g.add_edge(v, w, 1); } } } int fl = g.flow(s, t); if (2 * fl == count) { cout << "Yes" << endl; auto edges = g.edges(); int num = 0; for (auto e : edges) { if (s == e.from) {continue;} if (t == e.to) {continue;} if (0 == e.flow) {continue;} int i0 = e.from / W; int j0 = e.from % W; int i1 = e.to / W; int j1 = e.to % W; newS[i0][j0] = C[num]; newS[i1][j1] = C[num]; num++; } reverse(all(newS)); rep(j, H) {cout << newS[j] << endl;} return 0; } } cout << "No" << endl; return 0; }