#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10;
const int INF = 1e9 + 9;
const int B = 1e9 + 7;
int n, m, k;
int a[N][N], pr[N][N], pc[N][N];
int main() {
  cin >> n >> m >> k;
  int cnt = 0;
  for (int i = int(1); i <= int(n + n - 1); ++i) {
    char c;
    getchar();
    if (i & 1) {
      for (int j = int(2); j <= int(m); ++j) {
        c = getchar();
        int first = (c == 'N');
        cnt += first;
        pr[i / 2 + 1][j] = first;
      }
    } else {
      for (int j = int(1); j <= int(m); ++j) {
        c = getchar();
        int first = (c == 'N');
        cnt += first;
        pc[i / 2 + 1][j] = first;
      }
    }
  }
  if (k == 1) {
    if (cnt * 4 > n * (m - 1) + m * (n - 1))
      cout << "NO\n";
    else {
      cout << "YES\n";
      for (int i = int(1); i <= int(n); ++i) {
        for (int j = int(1); j <= int(m); ++j) cout << "1 ";
        cout << "\n";
      }
    }
    return 0;
  }
  cout << "YES\n";
  int ans = 0;
  if (n <= m) {
    for (int i = int(1); i <= int(n); ++i) {
      int mis = 0;
      for (int j = int(1); j <= int(m); ++j) {
        a[i][j] = a[i][j - 1] ^ pr[i][j];
        mis += (a[i - 1][j] ^ a[i][j]) ^ pc[i][j];
      }
      if (i > 1 && mis > m / 2) {
        for (int j = int(1); j <= int(m); ++j) a[i][j] ^= 1;
        mis = m - mis;
      }
      if (i > 1) ans += mis;
    }
  } else {
    for (int j = int(1); j <= int(m); ++j) {
      int mis = 0;
      for (int i = int(1); i <= int(n); ++i) {
        a[i][j] = a[i - 1][j] ^ pc[i][j];
        mis += (a[i][j - 1] ^ a[i][j]) ^ pr[i][j];
      }
      if (j > 1 && mis > n / 2) {
        for (int i = int(1); i <= int(n); ++i) a[i][j] ^= 1;
        mis = n - mis;
      }
      if (j > 1) ans += mis;
    }
  }
  for (int i = int(1); i <= int(n); ++i) {
    for (int j = int(1); j <= int(m); ++j) printf("%d ", 1 + a[i][j]);
    putchar('\n');
  }
  cerr << ans << "\n";
  return 0;
}
