#include <bits/stdc++.h>
using namespace std;
const int nmax = 2e3;
int v[nmax + 1][nmax + 1];
string s;
int a[nmax + 1][nmax + 1];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= 2 * n - 1; ++i) {
    cin >> s;
    for (int j = 1; j <= m - i % 2; ++j) {
      if (s[j - 1] == 'N') {
        v[i][j] = 1;
      }
    }
  }
  if (n > m) {
    for (int i = 2; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        a[i][j] = a[i - 1][j] ^ v[2 * (i - 1)][j];
      }
    }
    for (int j = 2; j <= m; ++j) {
      int cnt = 0;
      for (int i = 1; i <= n; ++i) {
        cnt += (a[i][j] == a[i][j - 1] ^ v[2 * i - 1][j - 1]);
      }
      if (cnt <= n / 2) {
        for (int i = 1; i <= n; ++i) a[i][j] ^= 1;
      }
    }
  } else {
    for (int i = 1; i <= n; ++i) {
      for (int j = 2; j <= m; ++j) {
        a[i][j] = a[i][j - 1] ^ v[2 * i - 1][j - 1];
      }
    }
    for (int i = 2; i <= n; ++i) {
      int cnt = 0;
      for (int j = 1; j <= m; ++j) {
        cnt += (a[i][j] == a[i - 1][j] ^ v[2 * (i - 1)][j]);
      }
      if (cnt <= m / 2) {
        for (int j = 1; j <= m; ++j) a[i][j] ^= 1;
      }
    }
  }
  if (k == 1) {
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      a[i][1] = 1;
      for (int j = 2; j <= m; ++j) {
        a[i][j] = 1;
        cnt += (a[i][j] != a[i][j - 1] ^ v[2 * i - 1][j - 1]);
      }
    }
    for (int i = 2; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        cnt += (a[i][j] != a[i - 1][j] ^ v[2 * (i - 1)][j]);
      }
    }
    if (cnt > (n * (m - 1) + (n - 1) * m) / 4) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i = 1; i <= n; ++i) {
    s.clear();
    for (int j = 1; j <= m; ++j) {
      s += ('2' - a[i][j]);
      s += ' ';
    }
    cout << s << "\n";
  }
  return 0;
}
