#include <bits/stdc++.h>
using namespace std;
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v);
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
istream &operator>>(istream &cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
void usaco(string filename) {
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long double pi = 3.14159265358979323846;
const long long mod = 1000000007;
long long n, m, q, k, l, r, x, y, z;
const long long template_array_size = 1e6 + 17598;
long long a[template_array_size];
long long b[template_array_size];
long long c[template_array_size];
string second, t;
string mat[505];
long long dr[4] = {0, 0, 1, -1};
long long dc[4] = {1, -1, 0, 0};
long long ret[505][505];
bool vis[300005];
long long col[300005];
vector<pair<long long, long long>> edges[300005];
long long id(long long r, long long c) { return r * m + c; }
void edge(long long a, long long b, long long c) {
  edges[a].push_back({b, c});
  edges[b].push_back({a, c});
}
bool dfs(long long v, long long c) {
  if (vis[v]) return 1;
  vis[v] = 1;
  col[v] = c;
  for (pair<long long, long long> x : edges[v]) {
    if (vis[x.first]) {
      if ((col[v] ^ col[x.first]) != x.second) {
        return 0;
      }
    } else {
      dfs(x.first, col[v] ^ x.second);
    }
  }
  return 1;
}
void solve(int tc = 0) {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) cin >> mat[i];
  bool pos = 1;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (mat[i][j] == 'X') {
        long long cnt = 0;
        vector<long long> p;
        for (long long d = 0; d < 4; d++) {
          long long ni = i + dr[d], nj = j + dc[d];
          if (mat[ni][nj] == '.') {
            ++cnt;
            p.push_back(d);
          }
        }
        if (cnt % 2 == 1) {
          pos = 0;
          break;
        } else if (cnt == 2) {
          long long a = id(i + dr[p[0]], j + dc[p[0]]);
          long long b = id(i + dr[p[1]], j + dc[p[1]]);
          edge(a, b, 1);
        } else if (cnt == 4) {
          edge(id(i - 1, j), id(i + 1, j), 0);
          edge(id(i, j - 1), id(i, j + 1), 0);
          edge(id(i - 1, j), id(i, j - 1), 1);
        }
        ret[i][j] = 5 * (cnt / 2);
      }
    }
  }
  if (!pos) {
    cout << "NO\n";
    return;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (mat[i][j] != 'X') {
        long long v = id(i, j);
        if (!vis[v]) {
          if (!dfs(v, 0)) {
            cout << "NO\n";
            return;
          }
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (mat[i][j] != 'X') {
        long long v = id(i, j);
        ret[i][j] = 1 + 3 * col[v];
      }
    }
  }
  cout << "YES\n";
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cout << ret[i][j] << " ";
    }
    cout << '\n';
  }
}
int main() {
  { ios_base::sync_with_stdio(false); }
  { cin.tie(NULL); }
  cout << setprecision(15) << fixed;
  int tc = 1;
  for (int t = 0; t < tc; t++) {
    solve(t);
  }
}
