#include #include using namespace std; using namespace atcoder; #define rep(i,n)for (int i = 0; i < int(n); ++i) #define rrep(i,n)for (int i = int(n)-1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template void chmax(T& a, const T& b) {a = max(a, b);} template void chmin(T& a, const T& b) {a = min(a, b);} using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; int main() { ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; vector s(h); rep(i, h) cin >> s[i]; int cnt = h; rep(i, h) { int bs = 0; rep(j, w) bs += s[i][j] == '#'; if (bs) { for(; i < h; i++) { int bs = 0; rep(j, w) bs += s[i][j] == '#'; if (bs == 0 || bs == w) { cout << "No\n"; return 0; } } break; } cnt--; } rep(s1, 1 << h) rep(s2, 1 << h) if ((s1 & s2) == 0 && __builtin_popcount(s1) == cnt) { vector t(h, string(w, '.')); { int k = h - 1; rrep(i, h) if (s1 >> i & 1) { rep(j, w) t[i][j] = s[k][j]; k--; } } rep(i, h) if (s2 >> i & 1) rep(j, w) t[i][j] = '#'; int source = h * w, sink = source + 1; mf_graph g(sink + 1); rep(i, h) rep(j, w) if (t[i][j] == '#') { if (i + j & 1) g.add_edge(i * w + j, sink, 1); else g.add_edge(source, i * w + j, 1); } for(int i = 0; i < h - 1; i++) for(int j = 0; j < w; j++) if ((i + j & 1) == 0 && t[i][j] == '#' && t[i+1][j] == '#') g.add_edge(i * w + j, (i + 1) * w + j, 1); for(int i = 1; i < h ; i++) for(int j = 0; j < w; j++) if ((i + j & 1) == 0 && t[i][j] == '#' && t[i-1][j] == '#') g.add_edge(i * w + j, (i - 1) * w + j, 1); for(int i = 0; i < h; i++) for(int j = 0; j < w - 1; j++) if ((i + j & 1) == 0 && t[i][j] == '#' && t[i][j+1] == '#') g.add_edge(i * w + j, i * w + j + 1, 1); for(int i = 0; i < h; i++) for(int j = 1; j < w; j++) if ((i + j & 1) == 0 && t[i][j] == '#' && t[i][j-1] == '#') g.add_edge(i * w + j, i * w + j - 1, 1); int f = g.flow(source, sink); int bcnt = 0; rep(i, h) rep(j, w) bcnt += t[i][j] == '#'; if (f * 2 == bcnt) { char nxt_c = 'a'; for(auto e: g.edges()) { if (e.from < h * w && e.to < h * w && e.flow) { t[e.from / w][e.from % w] = t[e.to / w][e.to % w] = nxt_c; if (nxt_c == 'z') nxt_c = 'A'; else nxt_c++; } } cout << "Yes\n"; rep(i, h) cout << t[i] << '\n'; return 0; } } cout << "No\n"; }