#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const int N = 505;
char c[N][N];
int comp[N][N];
int countComp = 0;
int color[N * N];
int res[N][N];
int n, m;
vector<int> adj[N * N];
inline bool inside(int u, int v) { return 0 < u && u <= n && 0 < v && v <= m; }
void DFS(int u, int v) {
  comp[u][v] = countComp;
  for (int x = u - 1; x <= u + 1; ++x) {
    for (int y = v - 1; y <= v + 1; ++y) {
      if (!inside(x, y) || c[x][y] != '.' || comp[x][y] > 0) continue;
      DFS(x, y);
    }
  }
}
void colorDFS(int u, int val) {
  color[u] = val;
  for (auto v : adj[u]) {
    if (color[v] > 0) {
      if (color[u] == color[v]) {
        cout << "NO\n";
        exit(0);
      }
      continue;
    }
    colorDFS(v, val ^ 3);
  }
}
int main() {
  srand(time(NULL));
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> c[i][j];
    }
  }
  countComp = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (c[i][j] == 'X' || comp[i][j] > 0) continue;
      ++countComp;
      DFS(i, j);
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (c[i][j] != 'X') continue;
      int cnt = 0;
      for (int k = 0; k < 4; ++k) {
        cnt += (inside(i + dx[k], j + dy[k]) && c[i + dx[k]][j + dy[k]] == '.');
      }
      if (cnt & 1) {
        cout << "NO\n";
        exit(0);
      }
      if (j > 0 && c[i][j - 1] == '.' && j < m && c[i][j + 1] == '.' &&
          comp[i][j - 1] != comp[i][j + 1]) {
        adj[comp[i][j - 1]].emplace_back(comp[i][j + 1]);
        adj[comp[i][j + 1]].emplace_back(comp[i][j - 1]);
      }
      if (i > 0 && c[i - 1][j] == '.' && i < n && c[i + 1][j] == '.' &&
          comp[i + 1][j] != comp[i - 1][j]) {
        adj[comp[i + 1][j]].emplace_back(comp[i - 1][j]);
        adj[comp[i - 1][j]].emplace_back(comp[i + 1][j]);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (color[comp[i][j]] > 0) continue;
      colorDFS(comp[i][j], 1);
    }
  }
  for (int j = 1; j <= m; ++j) {
    int val = ((j & 1) ? 1 : 4);
    res[1][j] = val;
    int pre = color[comp[1][j]];
    for (int i = 2; i <= n; ++i) {
      if (c[i][j] == 'X') continue;
      if (pre != color[comp[i][j]]) {
        val = (val == 1 ? 4 : 1);
      }
      res[i][j] = val;
      pre = color[comp[i][j]];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (c[i][j] != 'X') continue;
      for (int k = 0; k < 4; ++k) {
        int u = i + dx[k];
        int v = j + dy[k];
        if (!inside(u, v) || c[u][v] == 'X') continue;
        res[i][j] += res[u][v];
      }
    }
  }
  cout << "YES\n";
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cout << res[i][j] << " \n"[j == m];
    }
  }
}
