#include <bits/stdc++.h>
using namespace std;
long long ch[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
const long long N = 505;
long long n, m, cur;
long long a[N][N], res[N][N];
vector<long long> edges[N * N];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      char c;
      cin >> c;
      if (c == 'X') a[i][j] = 1;
      if (c == '.') a[i][j] = 0;
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (!a[i][j]) continue;
      vector<long long> tt;
      for (long long t = 0; t < 4; t++) {
        long long x = i + ch[t][0], y = j + ch[t][1];
        if (!a[x][y]) tt.push_back(x * m + y);
      }
      if ((long long)tt.size() & 1) {
        cout << "NO\n";
        return 0;
      }
      for (long long i = 0; i < (long long)tt.size(); i += 2) {
        edges[tt[i]].push_back(tt[i + 1]);
        edges[tt[i + 1]].push_back(tt[i]);
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (a[i][j] || res[i][j]) continue;
      queue<long long> qq;
      res[i][j] = 1, qq.push(i * m + j);
      while (!qq.empty()) {
        long long u = qq.front();
        qq.pop();
        long long i = u / m, j = u % m;
        for (auto t : edges[u]) {
          long long x = t / m, y = t % m;
          if (res[x][y]) continue;
          res[x][y] = 5 - res[i][j];
          qq.push(t);
        }
      }
    }
  }
  cout << "YES\n";
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (a[i][j]) {
        for (long long t = 0; t < 4; t++) {
          long long x = i + ch[t][0], y = j + ch[t][1];
          if (!a[x][y]) res[i][j] += res[x][y];
        }
      }
      cout << res[i][j] << " ";
    }
    cout << "\n";
  }
  cout << "\n";
}
