#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
const int N = 510;
int n, m;
char a[N][N];
int ans[N][N];
vector<int> E[N * N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] == 'X') {
        vector<int> id;
        for (int k = 0; k < 4; k++) {
          int x = i + dx[k], y = j + dy[k];
          int t = x * m + y - 1;
          if (a[x][y] == '.') id.push_back(t);
        }
        if (id.size() & 1) {
          puts("NO");
          return 0;
        } else if (id.size() == 2) {
          E[id[0]].push_back(id[1]);
          E[id[1]].push_back(id[0]);
        } else if (id.size() == 4) {
          E[id[0]].push_back(id[1]);
          E[id[1]].push_back(id[0]);
          E[id[2]].push_back(id[3]);
          E[id[3]].push_back(id[2]);
        }
      }
  puts("YES");
  memset(ans, -1, sizeof ans);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] == '.') {
        if (ans[i][j] != -1) continue;
        ans[i][j] = 1;
        queue<int> q;
        q.push(i * m + j - 1);
        while (q.size()) {
          int t = q.front();
          q.pop();
          int xx = t / m, yy = t % m + 1;
          for (int tt : E[t]) {
            int x = tt / m, y = tt % m + 1;
            if (ans[x][y] == -1) {
              ans[x][y] = 5 - ans[xx][yy];
              q.push(tt);
            }
          }
        }
      }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] == 'X') {
        ans[i][j] = 0;
        for (int k = 0; k < 4; k++) {
          int x = i + dx[k], y = j + dy[k];
          if (a[x][y] == '.') ans[i][j] += ans[x][y];
        }
      }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%d ", ans[i][j]);
    puts("");
  }
  return 0;
}
