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