#include <bits/stdc++.h>
using namespace std;
int h, w, k;
const int MAXN = 1100;
bool up[MAXN][MAXN];
bool lft[MAXN][MAXN];
bool tmpup[MAXN][MAXN];
bool tmplft[MAXN][MAXN];
int ans[MAXN][MAXN];
int tmpans[MAXN][MAXN];
int main() {
  scanf("%d %d %d", &h, &w, &k);
  for (int i = 0; i < h; i++) {
    for (int j = 1; j < w; j++) {
      char c;
      scanf(" %c", &c);
      lft[i][j] = (c == 'N');
    }
    if (i != h - 1) {
      for (int j = 0; j < w; j++) {
        char c;
        scanf(" %c", &c);
        up[i + 1][j] = (c == 'N');
      }
    }
  }
  bool inv = false;
  if (k == 1) {
    int cnt, cnteq;
    cnt = cnteq = 0;
    for (int i = 0; i < h; i++)
      for (int j = 1; j < w; j++) cnt++, cnteq += !lft[i][j];
    for (int i = 1; i < h; i++)
      for (int j = 0; j < w; j++) cnt++, cnteq += !up[i][j];
    if (3 * cnt <= 4 * cnteq) {
      printf("YES\n");
      for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++) printf("1%c", " \n"[j == w - 1]);
      return 0;
    }
    printf("NO\n");
    return 0;
  }
  if (h > w) {
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++)
        tmplft[j][i] = up[i][j], tmpup[j][i] = lft[i][j];
    swap(w, h);
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++)
        up[i][j] = tmpup[i][j], lft[i][j] = tmplft[i][j];
    inv = true;
  }
  ans[0][0] = 0;
  for (int i = 1; i < w; i++) ans[0][i] = ans[0][i - 1] ^ lft[0][i];
  for (int i = 1; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (!j || (j == w - 1) ||
          ((ans[i][j - 1] ^ lft[i][j]) == (ans[i - 1][j] ^ up[i][j]))) {
        ans[i][j] = ans[i - 1][j] ^ up[i][j];
      } else {
        ans[i][j + 1] = ans[i - 1][j + 1] ^ up[i][j + 1];
        ans[i][j] = ans[i][j + 1] ^ lft[i][j + 1];
        j++;
      }
    }
  }
  if (inv) {
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++) tmpans[j][i] = ans[i][j];
    swap(w, h);
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++) ans[i][j] = tmpans[i][j];
  }
  printf("YES\n");
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      printf("%d%c", ans[i][j] + 1, " \n"[j == w - 1]);
  ;
  return 0;
}
