#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++) #define reps(x, s) for(llint (x) = 0; (x) < (llint)(s).size(); (x)++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) #define sz(x) ((ll)(x).size()) #define ceil(x, y) (((x)+(y)-1) / (y)) #define all(x) (x).begin(),(x).end() #define outl(...) dump_func(__VA_ARGS__) #define inf 1e18 using namespace std; typedef long long llint; typedef long long ll; typedef pair P; bool exceed(ll x, ll y, ll m){return x >= m / y + 1;} struct edge{ ll to, cost; edge(){} edge(ll a, ll b){ to = a, cost = b; } }; template ostream& operator << (ostream& os, vector& vec) { for(int i = 0; i ostream& operator << (ostream& os, pair& pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; } template ostream& operator << (ostream& os, map& map_var) { for(typename map::iterator itr = map_var.begin(); itr != map_var.end(); itr++) { os << "(" << itr->first << ", " << itr->second << ")"; itr++; if(itr != map_var.end()) os << ","; itr--; } return os; } template ostream& operator << (ostream& os, set& set_var) { for(typename set::iterator itr = set_var.begin(); itr != set_var.end(); itr++) { os << *itr; ++itr; if(itr != set_var.end()) os << " "; itr--; } return os; } void dump_func() {cout << endl;} template void dump_func(Head &&head, Tail &&... tail) { cout << head; if(sizeof...(Tail) > 0) cout << " "; dump_func(std::move(tail)...); } struct Dinic{ struct edge{ llint to, cap, rev; edge(llint a, llint b, llint c){ to = a, cap = b, rev = c; } }; int n; vector > G; vector level, iter; Dinic(){} Dinic(int n){ this->n = n; G.resize(n+1); level.resize(n+1); iter.resize(n+1); } void init(){ for(int i = 0; i <= n; i++) G[i].clear(); } void add_edge(int s, int t, llint cap) { G[s].push_back(edge(t, cap, G[t].size())); G[t].push_back(edge(s, 0, G[s].size()-1)); } void bfs(int s) { for(int i = 0; i <= n; i++) level[i] = inf; level[s] = 0; queue Q; Q.push(s); while(Q.size()){ int v = Q.front(); Q.pop(); for(int i = 0; i < G[v].size(); i++){ int u = G[v][i].to; if(G[v][i].cap <= 0 || level[u] < inf) continue; level[u] = level[v] + 1; Q.push(u); } } } llint dfs(int v, llint f, int t) { if(v == t) return f; llint ret; for(llint &i = iter[v]; i < G[v].size(); i++){ if(level[v] >= level[G[v][i].to] || G[v][i].cap <= 0) continue; ret = dfs(G[v][i].to, min(f, G[v][i].cap), t); if(ret > 0){ G[v][i].cap -= ret; G[G[v][i].to][G[v][i].rev].cap += ret; return ret; } } return 0; } llint calc(int s, int t) { llint ret = 0, flow; while(1){ bfs(s); if(level[t] >= inf) break; for(int i = 0; i <= n; i++) iter[i] = 0; while(1){ flow = dfs(s, inf, t); if(flow <= 0) break; ret += flow; } } return ret; } }; ll h, w, maxh; char c[15][15]; char d[15][15]; ll dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; Dinic dc(305); ll ans[15][15]; void dfs(int p, int q) { if(p == h+1){ if(q <= maxh) return; ll S = h*w+w+1, T = S+1; dc.init(); ll lcnt = 0, rcnt = 0; rep(y, 1, h) rep(x, 1, w){ ll v = y*w+x; if((x+y)%2 == 0){ if(d[x][y] == '#') dc.add_edge(S, v, 1), lcnt++; rep(i, 0, 3){ ll nx = x + dx[i], ny = y + dy[i]; if(nx < 1 || nx > w || ny < 1 || ny > h) continue; ll nv = ny*w+nx; dc.add_edge(v, nv, 1); } } else if(d[x][y] == '#') dc.add_edge(v, T, 1), rcnt++; } if(lcnt != rcnt) return; /*for(int y = h; y >= 1; y--){ rep(x, 1, w) cout << d[x][y]; cout << endl; } cout << endl;*/ if(dc.calc(S, T) != lcnt) return; ll id = 0; rep(y, 1, h) rep(x, 1, w){ ll v = y*w+x; if((x+y)%2 == 0) continue; if(d[x][y] != '#') continue; for(auto e : dc.G[v]){ if(e.cap == 0) continue; ll nx = (e.to-1) % w + 1, ny = (e.to-1) / w; ans[x][y] = ans[nx][ny] = id++; } } outl("Yes"); for(int y = h; y >= 1; y--){ rep(x, 1, w){ if(d[x][y] == '.') cout << '.'; else if(ans[x][y] < 26) cout << (char)('a'+ans[x][y]); else cout << (char)('A'+ans[x][y]-26); } cout << endl; } exit(0); } if(q <= maxh){ rep(x, 1, w) d[x][p] = c[x][q]; dfs(p+1, q+1); } rep(x, 1, w) d[x][p] = '#'; dfs(p+1, q); rep(x, 1, w) d[x][p] = '.'; dfs(p+1, q); } int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> h >> w; for(int y = h; y >= 1; y--){ rep(x, 1, w) cin >> c[x][y]; } rep(y, 1, h) rep(x, 1, w) if(c[x][y] == '#') chmax(maxh, y); rep(y, 1, maxh){ bool flag = false; rep(x, 1, w) if(c[x][y] == '#') flag = true; if(!flag){ outl("No"); return 0; } flag = false; rep(x, 1, w) if(c[x][y] == '.') flag = true; if(!flag){ outl("No"); return 0; } } dfs(1, 1); outl("No"); return 0; }