#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
int n, m, a[505][505];
char s[505][505];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; i++) {
    int col = 0;
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == '.') a[i][j] = ((i + col) & 1) ? 1 : 4;
      if (s[i][j] == 'X') {
        int cnt = 0;
        for (int k = 0; k < 4; k++) cnt += s[i + dx[k]][j + dy[k]] == '.';
        if (cnt & 1) {
          puts("NO");
          return 0;
        }
        if (s[i - 1][j] == 'X') col ^= 1;
      }
    }
  }
  puts("YES");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (s[i][j] == 'X') {
        int cnt = 0;
        for (int k = 0; k < 4; k++) cnt += a[i + dx[k]][j + dy[k]];
        printf("%d ", cnt);
      } else
        printf("%d ", a[i][j]);
    puts("");
  }
  return 0;
}
