#include <bits/stdc++.h>
using namespace std;
inline int Rd() {
  int s = 0;
  char fl = 0, c = getchar();
  while (c < '0' || c > '9') fl |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
  return fl ? -s : s;
}
const int N = 250005;
int dx[4] = {0, 0, -1, 1}, dy[4] = {-1, 1, 0, 0};
int n, m, a[505][505], ans[505][505];
char c[505];
vector<int> vec[N];
inline int Pos(int x, int y) { return (x - 1) * m + y; }
int vit[N], deg[N], fl = 0;
void DFS(int x) {
  for (int i = 0, siz = vec[x].size(); i < siz; ++i) {
    int y = vec[x][i];
    if (!vit[y])
      vit[y] = 5 - vit[x], DFS(y);
    else if (vit[y] == vit[x])
      return fl = 1, void();
    if (fl) return;
  }
}
inline void AddEdge(int x, int y) { vec[x].push_back(y), vec[y].push_back(x); }
inline void Solve() {
  memset(ans, 0, sizeof(ans));
  n = Rd(), m = Rd();
  for (int i = 1; i <= n; ++i) {
    scanf("%s", c + 1);
    for (int j = 1; j <= m; ++j) a[i][j] = c[j] == '.';
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j)
      if (!a[i][j]) {
        int num = 0, d[4];
        for (int k = 0; k < 4; ++k) {
          int px = i + dx[k], py = j + dy[k];
          if (px < 1 || px > n || py < 1 || py > m) continue;
          num += a[px][py];
          if (a[px][py] == 1) d[num] = Pos(px, py);
        }
        if (num == 3 || num == 1) return puts("NO"), void();
        if (num == 4)
          AddEdge(d[1], d[3]), AddEdge(d[3], d[2]), AddEdge(d[2], d[4]);
        else if (num == 2)
          AddEdge(d[1], d[2]);
      }
  }
  for (int i = 1; i <= n * m; ++i) {
    if (!vit[i]) {
      vit[i] = 1, DFS(i);
      if (fl) return puts("NO"), void();
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      if (!a[i][j]) {
        for (int k = 0; k < 4; ++k) {
          int px = i + dx[k], py = j + dy[k];
          if (px < 1 || px > n || py < 1 || py > m) continue;
          if (a[px][py] == 1) ans[i][j] += vit[Pos(px, py)];
        }
      } else
        ans[i][j] = vit[Pos(i, j)];
    }
  puts("YES");
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) printf("%d ", ans[i][j]);
    puts("");
  }
}
int main() {
  Solve();
  return 0;
}
