#include using namespace std; int main(){ int H, W; cin >> H >> W; vector s(H); for (int i = H - 1; i >= 0; i--){ cin >> s[i]; } int mx = H; bool ok = true; for (int i = H - 1; i >= 0; i--){ bool ok1 = false, ok2 = false; for (int j = 0; j < W; j++){ if (s[i][j] == '.'){ ok1 = true; } if (s[i][j] == '#'){ ok2 = true; } } if (!ok1){ ok = false; } if (ok2 && mx == H){ mx = i; } if (!ok2 && mx != H){ ok = false; } } if (!ok){ cout << "No" << endl; } else if (mx == H){ cout << "Yes" << endl; } else { int cnt = mx + 1; bool ok2 = false; vector ans; for (int i = 0; i < (1 << H); i++){ if (__builtin_popcount(i) == cnt){ vector p; for (int j = 0; j < H; j++){ if ((i >> j & 1) == 1){ p.push_back(j); } } vector s2(H, string(W, '.')); for (int j = 0; j < p[cnt - 1]; j++){ s2[j] = string(W, '#'); } for (int j = 0; j < cnt; j++){ s2[p[j]] = s[j]; } vector> dp(H * W + 1, vector(1 << W, false)); dp[0][(1 << W) - 1] = true; for (int j = 0; j < H * W; j++){ for (int k = 0; k < (1 << W); k++){ if (dp[j][k]){ int x = j / W, y = j % W; if (s2[x][y] == '.'){ if ((k >> (W - 1) & 1) == 1){ int k2 = k - (1 << (W - 1)); dp[j + 1][k2 * 2 + 1] = true; } } else { if ((k >> (W - 1) & 1) == 1){ int k2 = k - (1 << (W - 1)); dp[j + 1][k2 * 2] = true; if (y > 0){ if ((k & 1) == 0){ dp[j + 1][k2 * 2 + 3] = true; } } } else { dp[j + 1][k * 2 + 1] = true; } } } } } if (dp[H * W][(1 << W) - 1]){ ok2 = true; vector c; for (int j = 0; j < 26; j++){ c.push_back('a' + j); } for (int j = 0; j < 26; j++){ c.push_back('A' + j); } int id = 0; int S = (1 << W) - 1; for (int j = H * W - 1; j >= 0; j--){ int x = j / W, y = j % W; if ((S & 1) == 0){ if (dp[j][S / 2]){ S = S / 2; } else { S = S / 2 + (1 << (W - 1)); } } else if (s2[x][y] == '.'){ if (dp[j][(S - 1) / 2]){ S = (S - 1) / 2; } else { S = (S - 1) / 2 + (1 << (W - 1)); } } else { bool h = false; if (y > 0){ if (s2[x][y - 1] == '#'){ if ((S >> 1 & 1) == 1){ if (dp[j][(S - 3) / 2]){ S = (S - 3) / 2; h = true; } else if (dp[j][(S - 3) / 2 + (1 << (W - 1))]){ S = (S - 3) / 2 + (1 << (W - 1)); h = true; } } } } if (h){ s2[x][y] = c[id]; s2[x][y - 1] = c[id]; id++; } else { s2[x][y] = c[id]; s2[x - 1][y] = c[id]; id++; S = (S - 1) / 2; } } } ans = s2; break; } } } if (!ok2){ cout << "No" << endl; } else { cout << "Yes" << endl; for (int i = H - 1; i >= 0; i--){ cout << ans[i] << endl; } } } }