#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, sum = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * f;
}
inline long long readLL() {
  long long f = 1, sum = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1LL;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * f;
}
int n, m;
char s[505][505];
int ans[505][505];
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; i++) {
    int change = 0;
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == 'X') {
        change ^= (s[i - 1][j] == 'X');
        int num = 0;
        if (s[i - 1][j] == '.') num++;
        if (s[i + 1][j] == '.') num++;
        if (s[i][j - 1] == '.') num++;
        if (s[i][j + 1] == '.') num++;
        if (num & 1) {
          puts("NO");
          return 0;
        }
      } else
        ans[i][j] = ((j + change) & 1) ? 1 : 4;
    }
  }
  puts("YES");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == 'X') {
        int num = 0;
        if (s[i - 1][j] == '.') num += ans[i - 1][j];
        if (s[i + 1][j] == '.') num += ans[i + 1][j];
        if (s[i][j - 1] == '.') num += ans[i][j - 1];
        if (s[i][j + 1] == '.') num += ans[i][j + 1];
        printf("%d ", num);
      } else
        printf("%d ", ans[i][j]);
    }
    puts("");
  }
  return 0;
}
