#include <bits/stdc++.h>
#pragma GCC target("avx2,fma")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long IOS = []() {
  ios::sync_with_stdio(0);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  return 0;
}();
template <class T>
void _W(const T &x) {
  cout << x;
}
template <class T>
void _W(T &x) {
  cout << x;
}
template <class T, class U>
void _W(const pair<T, U> &x) {
  _W(x.first);
  putchar(' ');
  _W(x.second);
}
template <class T>
void _W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); _W(*i++)) cout << ' ';
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
  _W(head);
  cout << ", ";
  W(tail...);
}
inline string cn(long long i) {
  stringstream ss;
  ss << i;
  return ss.str();
}
const long long N = 5e2 + 10;
long long tr[N];
long long n, m;
char mp[N][N];
long long t[N][N];
long long vis[N][N], ans[N][N];
long long dir[10] = {1, 0, -1, 0, 0, 1, 0, -1};
void build(long long u, long long l, long long r) {
  if (l == r) {
    tr[u] = 0;
    return;
  }
  long long mid = l + r >> 1;
  build(u << 1, l, mid);
  build(u << 1 | 1, mid + 1, r);
}
long long judge(long long x, long long y) {
  long long ans = 0;
  for (long long i = 0; i < 4; i++) {
    if (mp[x + dir[2 * i]][y + dir[2 * i + 1]] == '.') ans++;
  }
  return ans;
}
void dfs(long long x, long long y, long long k, long long d) {
  vis[x][y] = 1;
  if (k == 1) {
    for (long long i = 0; i < 4; i++) {
      if (mp[x + dir[2 * i]][y + dir[2 * i + 1]] == 'X' &&
          vis[x + dir[2 * i]][y + dir[2 * i + 1]] == 0) {
        dfs(x + dir[2 * i], y + dir[2 * i + 1], 0, d);
      }
    }
  } else {
    if (t[x][y] == 2) {
      for (long long i = 0; i < 4; i++) {
        if (mp[x + dir[2 * i]][y + dir[2 * i + 1]] == '.' &&
            vis[x + dir[2 * i]][y + dir[2 * i + 1]] == 0) {
          ans[x + dir[2 * i]][y + dir[2 * i + 1]] = 5 - d;
          dfs(x + dir[2 * i], y + dir[2 * i + 1], 1, 5 - d);
        }
      }
    } else {
      if (vis[x - 1][y]) {
        ans[x + 1][y] = ans[x - 1][y];
        ans[x][y + 1] = ans[x][y - 1] = 5 - ans[x - 1][y];
      } else if (vis[x + 1][y]) {
        ans[x - 1][y] = ans[x + 1][y];
        ans[x][y + 1] = ans[x][y - 1] = 5 - ans[x + 1][y];
      } else if (vis[x][y + 1]) {
        ans[x][y - 1] = ans[x][y + 1];
        ans[x - 1][y] = ans[x + 1][y] = 5 - ans[x][y + 1];
      } else {
        ans[x][y + 1] = ans[x][y - 1];
        ans[x - 1][y] = ans[x + 1][y] = 5 - ans[x][y - 1];
      }
      for (long long i = 0; i < 4; i++) {
        vis[x + dir[2 * i]][y + dir[2 * i + 1]] = 1;
      }
      for (long long i = 0; i < 4; i++) {
        dfs(x + dir[2 * i], y + dir[2 * i + 1], 1,
            ans[x + dir[2 * i]][y + dir[2 * i + 1]]);
      }
    }
  }
}
void solve() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cin >> mp[i][j];
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (mp[i][j] == 'X') {
        t[i][j] = judge(i, j);
        if (t[i][j] & 1) {
          cout << "NO" << '\n';
          return;
        }
        ans[i][j] = t[i][j] * 5 / 2;
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (mp[i][j] == '.') {
        if (!vis[i][j]) {
          ans[i][j] = 1;
          dfs(i, j, 1, 1);
        }
      }
    }
  }
  cout << "YES" << '\n';
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cout << ans[i][j] << " ";
    }
    cout << '\n';
  }
}
signed main() {
  n = 10;
  build(1, 1, n);
  long long tt = 1;
  while (tt--) {
    solve();
  }
}
